Logo
(追記) (追記ここまで)

32327번 - Dusa And The Yobis 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 1024 MB34427223479.592%

문제

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 10 and it encounters a Yobi of size 6, Dusa eats the Yobi and expands to size 10 + 6 = 16.

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.

입력

The first line of input contains a positive integer, D, representing Dusa’s starting size.

The remaining lines of input contain positive integers representing the sizes of the Yobis in order.

출력

Output the positive integer, R, which is Dusa’s size when it eventually runs away.

제한

예제 입력 1

5
3
2
9
20
22
14

예제 출력 1

19

Dusa is large enough to eat the Yobi of size 3. This brings Dusa’s size to 8. Dusa is large enough to eat the Yobi of size 2. This brings Dusa’s size to 10. Dusa is large enough to eat the Yobi of size 9. This brings Dusa’s size to 19. The Yobi of size 20 causes Dusa to run away.

예제 입력 2

10
10
3
5
13

예제 출력 2

10

The Yobi of size 10 causes Dusa to run away, leaving its size unchanged.

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2024 > CCC 2024 Junior Division 2번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /