Pianino
의견: 0
\(6^{th}\) round, February \(6^{th}\) 2016
Young Mirka is an amateur musician. She plays the mul\(ti-pi\)ano. A mul\(ti-pi\)ano consists of an infinite
number of mul\(ti-ke\)ys, denoted with integers that can be interpreted as the pitch. A mul\(ti-co\)mposition
(a composition written for a mul\(ti-pi\)ano) can be represented with a finite array of integers, where
integers denote the order of mul\(ti-ke\)ys to press in order to play the mul\(ti-co\)mposition.
Young Mirka has heard a mul\(ti-co\)mposition on the mul\(ti-ra\)dio and now she wants to play it. Unfor-
tunately, she cannot hear exactly which key was pressed, but instead she can hear whether the pressed
mul\(ti-ke\)y was higher, lower or equal to the previously played key (a higher key is denoted with a larger
number). Therefore she has decided to play the composition in the following way:
• before playing, she will choose one n\(on-ne\)gative integer \(K\)
• in the beginning, she will play the correct mul\(ti-ke\)y (her mul\(ti-te\)acher told her which mul\(ti-ke\)y
that is)
• when she hears that the mul\(ti-ke\)y played in the mul\(ti-co\)mposition is higher than the previous
mul\(ti-ke\)y played in the mul\(ti-co\)mposition, she will play the mul\(ti-ke\)y denoted with the integer
larger than the mul\(ti-ke\)y she played previously by \(K\)
• analogously, when she hears that the mul\(ti-ke\)y played in the mul\(ti-co\)mposition is lower than the
previous mul\(ti-ke\)y played in the mul\(ti-co\)mposition, she will play the mul\(ti-ke\)y denoted with the
integer smaller than the mul\(ti-ke\)y she played previously by \(K\)
• when she hears that the mul\(ti-ke\)y played in the mul\(ti-co\)mposition is equal to the previous
mul\(ti-ke\)y played in the mul\(ti-co\)mposition, she will repeat the mul\(ti-ke\)y she played previously
Notice that, when Mirka is playing, she does not compare the pitch of the keys she played to the pitch
of the keys from the composition.
Help Mirka choose the integer \(K\) in order to hit as many correct pitches as possible.
The first line of input contains the integer \(N\) (2 ⩽\(N\) ⩽\(10^{6}\)), the number of mul\(ti-ke\)ys in the multi-
composition on the mul\(ti-ra\)dio.
The second line of input contains \(N\) integers \(a@@RISE_MATH_BLOCK_0@@i\) ⩽\(10^{9}\)), the mul\(ti-ke\)ys played in the
mul\(ti-co\)mposition.
The first line of output must contain the maximum number of mul\(ti-ke\)ys that Mirka can play correctly.
The second line of output must contain the n\(on-ne\)gative number \(K\) that Mirka must choose in order
to hit as many correct pitches as possible. The number must be smaller than or equal to \(2 \cdot 10^{9}\).
Please note: The required number does not have to be unique, but will surely exist within the given
constraints.
5
1 2 0 3 1
7
2 1 -6 -2 1 6 10output
3
2
5
4Clarification of the first example: Mirka will play the following keys, respectively: 1, 2, 0, 3, 1. Denoted
in bold are the keys that she played correctly.
Clarification of the second example: Mirka will play the following keys, respectively: 2, -2, -6, -2, 2, 6,
10.
평가 및 의견
Pianino
Log in to rate problems.
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Pianino