GLJIVE - GLJIVE


In front of Super Mario there are 10 mushrooms, arranged in a row. A certain amount of points is awarded for picking each of the mushrooms. Super Mario must pick mushrooms in order they appear, but is not required to pick them all – his goal is to score a number of points as close as possible to 100.

In case there exist two such numbers which are equally close to 100 (e.g. 98 and 102), Mario will pick the greater one (in this case 102).

Help Super Mario and tell him how many points he will score.

Input

Input consists of 10 lines, each of which contains one positive integer less than or equal to 100, denoting the scores awarded for picking each mushroom, in the order that Mario can pick them in.

Output

The first and only line of output must contain the required number of points.

Example

Input:
10
20
30
40
50
60
70
80
90
100

Output:
100

hide comments
mukesh tiwari: 2011-05-20 17:39:46

read the Paranaoid Android comments before solving this problem.

sudipto das: 2011-04-27 14:54:37

problem description is misleading...

Anurag Atri: 2011-03-15 17:13:30

@Paranoid :
thank you . i dont think it would have been possible without your help . :)

S: 2011-03-05 08:28:08

@Paranoid Android
Thx that really helped

Rachmawan Atmaji Perdana: 2011-03-05 00:41:25

How much you'll take at the k-th row is the summation from row 1 to k

S: 2011-03-04 19:20:38

@Paranoid Android
Why isn't the 2nd o/p of the sample test case in the pdf 89 but 87?

@S : You can't select 89 only. You have to start from 1 and keep selecting mushrooms. So when you reach 89 you have already scored 87. So you stop there. You can't discard the previously selected mushrooms. Hope it helps.

Last edit: 2011-03-05 06:49:35
Paranoid Android: 2011-03-04 06:58:53

For those who can't decipher what the problem asks please read my rephrased statement below :

Select mushrooms in order starting from 1. You can't select mushrooms like 1,3,7 but it should be 1,2,3,4...10. You can stop in between if you get a value "closest" to 100. If there is a tie between two numbers equally "close" to 100 select the larger one.

If you are still not getting it type "coci gljive" in google, then open the first pdf link. There will be other sample cases. That will help you to understand.

Last edit: 2011-03-05 06:50:13
Mohamed Ramzy: 2011-02-24 15:19:36

still i can't understand it , someone explain what is required.
@:D : even your explanation give WA

Last edit: 2011-02-24 15:19:59
:D: 2011-02-21 18:40:58

You can take any contiguous sequence of mushrooms, starting from the first.


Added by:akaki
Date:2011-02-13
Time limit:0.205s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM64
Resource:coci