Canadian Computing Competition: 2024 Stage 1, Junior #2
Dusa eats Yobis, but only Yobis of a certain size.
If Dusa encounters a Yobi that is smaller than itself, it eats the Yobi, and absorbs its size.
For example, if Dusa is of size
If Dusa encounters a Yobi that is the same size as itself or larger, Dusa runs away without eating the Yobi.
Dusa is currently facing a line of Yobis and will encounter them in order. Dusa is guaranteed to eventually encounter a Yobi that causes it to run away. Your job is to determine Dusa's size when this happens.
Input Specification
The first line of input contains a positive integer,
The remaining lines of input contain positive integers representing the sizes of the Yobis in order.
Output Specification
Output the positive integer,
Sample Input 1
5
3
2
9
20
22
14
Output for Sample Input 1
19
Explanation of Output for Sample Input 1
Dusa is large enough to eat the Yobi of size
Sample Input 2
10
10
3
5
13
Output for Sample Input 2
10
Explanation of Output for Sample Input 2
The Yobi of size
Comments
sigma
wtf, why we need except???!!!:(
This comment is hidden due to too much negative feedback. Show it anyway.
please dont put answers in the comments (i think this is solution idk)
how many inputs do we need
use a while true loop bc we don't know when duza runs away
while dusa can eat the yobis
This comment is hidden due to too much negative feedback. Show it anyway.
Is there any test case where Dusa can eat all the Yobis?
No, because Dusa is guaranteed to eventually encounter a Yobi that causes it to run away