<PREV Problem:
NEXT>
Solved by 358 users: ...
UserDateAttemptTimeCMSC
fetetriste23 nov 2007C++1400.51189 
Micota11 mar 2010FPC600.33192 
glueray11 nov 2006C++600.02195 
Philip_PV12 jul 2008C++500.14195 
glueray11 nov 2006C++500.02198 
Aleris_S30 sep 2015C1300.01199 
Philip_PV12 jul 2008C++400.13199 
tnsantosh26 dec 2007C++2400.44199 
cyberian07 may 2007C++1303.53199 
Zorgan24 oct 2011C++800.02203 
Micota11 mar 2010FPC500.33204 
tnsantosh19 dec 2007C++2300.44204 
Zorgan24 oct 2011C++700.02207 
g20151309 may 2006C++100.02209 
zmy23 apr 2006C++600.02209 
Zorgan24 oct 2011C++600.02210 
fetetriste23 apr 2007C++800.49210 
Languages
C++
186
FPC
106
Java
37
C
19
Kylix
13
Ruby
1
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 
 > 

Minimizing number of steps

Time limit = 5 seconds

Petya wants to organize programming contest in his institute and he has to pass some consecutive bureaucratic procedures.

At each step Petya get or pay some money.

He may pay 100 coins to skip next bureaucratic procedures or 200 coins to skip next two procedures or k*100 coins to skip next k.

Please, help Petya to minimize number of bureaucratic procedures.

At the beginning Petya has 0 coins. The last and the first procedures should be passed.

He cannot have negative number of coins.

Input The first line contains number N, (1 ≤ N ≤ 1000 ). Next line contains N integer numbers each less than 10000 in absolute value.

Output Output minimal number of procedures Petya should pass through. or output "-1" if it is impossible to pass trough bureaucratic barrier.

Input#1
1
100
Output#1
1
Input#2
1
-20
Output#2
-1
Input#3
4
120 20 20 20
Output#3
3
Input#4
6
30 30 30 30 30 30
Output#4
5


Author:

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 210ms

SW soft NIX
ID = 18.232.51.247