what is the error in this code,i have tried all the test cases in the comments and in the forums,it gives correct answer but codechef gives it wrong
In case you have 8 candles of each type you can represent all positive numbers till 99999999 whereas you’re only checking for ages less than 10000.
To see this yourself try this testcase:
1 8 8 8 8 8 8 8 8 8 8
I’m not going to give away the answer here but all I’ll tell you is this, if you do iterate till 10^9 you will get a TLE and if you don’t you’ll get wrong answer.
Try some other approach.