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
ashimk: 2018-03-17 11:51:56

Unclear explanation of the problem costed me 3 WA's ..... Deserves Downvote :p)
PS: Comments came into rescue!

rob_in_1: 2018-03-05 19:21:51

10 20 30 50 60 70 75 80 90 100
what will be the answer for this case ?
It should be 100 but it is 110.

ameyanator: 2018-03-01 15:56:09

yaasss! My 100th!! :D

Once you know what to do it's an easy implementation but the problem statement is not very clear

srjsunny: 2018-02-22 20:53:14

question statement not at all clear

prakash1108: 2018-01-15 13:16:19

if sum>100,break the loop ,i.e not take all the input.

mpride44: 2017-12-28 19:50:43

ac in 1 go...
let me explain --- u have an array of 10 elements now u have to add elements of array consecutively.let s1 is sum before addition of any element 'd' (say) and s2 is sum after addition of 'd'.Now u have to check which one is more close to 100 is s1 or s2 .update the original sum 's' with one which is more close to 100.
for ex--
1,2,3,5,8,13,21,34,55,89
clearly before addition s=0, s1=0, s2=0
now start adding elements of array from 1 to next and then next and so on.
when u reach 34 s=53 .Now next element for addition is 34 and when u add it sum is 87.before addition s=53 so here s1=53 and s2=87 .Check which is more close to 100 s1 or s2.here s2 is more close so s=s2=87
next element is 55 and we have s=87,s1=87(before addition) if we add 55 then sum is 142.here s2=142 and s1=87 clearly 87 is more close to 100 so our result is 87 print 87...this is the ans
i hope this will help u...all the best

shubhamkr2020: 2017-12-21 17:41:09

Why so many downvotes ??
I think it is a good question.

nermatibhanu: 2017-06-03 08:49:02

Please read comments to get clarity abt question

anurag_333: 2017-05-31 19:32:05

can anyone tell me how it could have been done if the question was as we understood at first i.e
we can skip elements in between the array of ten elements

mrigank9: 2017-05-05 08:30:26

AC in one go :) comments are the key :p


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