luogu#P7799. [COCI 2015/2016 #6] PIANINO

[COCI 2015/2016 #6] PIANINO

Problem Description

Mirka\text{Mirka} is an amateur pianist, and she is learning a piece of music. However, she is not very good at finding the correct pitch, so she uses a special technique.

There are NN notes in the piece, and each note has a standard pitch aia_i. Mirka\text{Mirka} can play the first note accurately, and then she will choose a value KK.

  • If the standard pitch of the next note is greater than the standard pitch of the current note, she will increase the pitch she is currently playing by KK.
  • If the standard pitch of the next note is less than the standard pitch of the current note, she will decrease the pitch she is currently playing by KK.
  • If the standard pitch of the next note is equal to the standard pitch of the current note, she will not change the pitch she is currently playing.

If the pitch she is currently playing is equal to the standard pitch of the current note, then Mirka\text{Mirka} has played a note correctly. Please help her find a non-negative integer KK so that she plays the maximum number of notes correctly.

Input Format

The first line contains an integer NN.

The second line contains NN integers aia_i, where aia_i is the standard pitch of the ii-th note.

Output Format

The first line outputs an integer, the maximum number of notes that Mirka\text{Mirka} can play correctly.

The second line outputs a non-negative integer, the value of KK. You only need to output any KK that satisfies the requirement.

5
1 2 0 3 1
3
2
7
2 1 -6 -2 1 6 10
5
4

Hint

[Sample 1 Explanation]

When K=2K=2, the pitches she plays are 1, 3, 1, 3, 1. In total, she plays 33 notes correctly.

Note that K=1K=1 is also a feasible solution.

[Sample 2 Explanation]

When K=4K=4, the pitches she plays are 2, -2, -6, -2, 2, 6, 10. In total, she plays 55 notes correctly.

[Constraints]

For 100%100\% of the testdata, 2N1062\le N\le 10^6, 109ai109-10^9\le a_i\le 10^9.

[Scoring Method]

This problem uses an unofficial self-written Special Judge, which can also be obtained from the attachments. Everyone is welcome to Hack (via private message or by posting). Hack testdata are placed separately at the end; the corresponding test points all have a score of 0.

[Source]

Translated from COCI 2015-2016 CONTEST #6 T3 PIANINO.

The score of this problem follows the original COCI setting, full score 100100.

Translated by ChatGPT 5