Solved by 67 users: ...
UserDateAttemptTimeCMSC
kornakovBSU`11 dec 2010`C++1500.02117
kornakovBSU`11 dec 2010`C++1400.02124
Philip_PV`18 oct 2008`C900.01131
Darii`11 dec 2010`C++900.01131
Darii`10 dec 2010`C++600.01136
Philip_PV`18 oct 2008`C700.01136
kornakovBSU`11 dec 2010`C++1300.01142
kornakovBSU`10 dec 2010`C++1200.01162
stasg7`08 dec 2008`C++200.01166
david_it21`15 dec 2008`Ruby400.07168
svirg`01 oct 2008`C++200.04175
Arsuit`27 sep 2008`C++1200.04179
JohnJones_001`27 sep 2008`C400.01180
WsemirZ`24 sep 2008`Kylix100.01182
Darii`08 dec 2010`C++300.01184
kornakovBSU`07 sep 2010`C++600.01191
Darii`08 dec 2010`C++200.01195
N1k1tung`29 sep 2008`C++300.04199
 C++ 50 C 9 Java 4 Kylix 2 Ruby 1 Python 1 FPC 1
` >  >  >  >  >  >  >  >  >  > `

Time limit = 2 second(s)

Memory limit = 64 Mb

The physics professor needs a program which detects whether a sequence of numbers describes fading oscillations for the analysis of experimental data.

After long arguing you got the definition of a fading oscillations.

A local maximum is one or more consequent elements with smaller elements both to the left and to the right. Local minimum is defined analogously. According to this definition, the first and the last values in the sequence are not considered to be a minimum or a maximum.

A sequence is called "fading oscillations" if it has got at least one local minimum and one local maximum and, moreover, the tail of the sequence lies in [min, max] where min and max are the values of the last (before the tail) local minimum and local maximum (the last condition is to be applied only after the first minimum and maximum are reached).

You failed to assure the prof that the definition looks like describing a sequence of non-increasing oscillations. Well, the customer is always right.

Input The first line contains the length of the sequence N, 0 < N < 100000. A sequence of integers from [-108, 108], delimited by spaces, follows.

Output Print YES and the last values of min and max if the sequence is fading oscillations and NO otherwise.

 Input#1```3 1 1 1 ``` Output#1```NO ```
 Input#2```4 5 6 5 4 ``` Output#2```NO ```
 Input#3```5 1 -2 -5 3 0 ``` Output#3```YES -5 3 ```

Author:
Artem Voroztsov, individual MIPT contest, 21 sep., 2008
20 September 2008

 © acm.mipt DevGroupThe page was generated in 170ms