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

32046번 - Snacks within 300 Yen 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
8 초 (추가 시간 없음) 1024 MB36732529489.908%

문제

Your friend, Greedy George, visits a candy store for his snacks for the school excursion, grabbing 300 yen in his hand. In the candy store, one item of each different kind of snack is placed in a line on the shelf. After entering the store, Greedy George picks up a shopping basket and starts checking the snacks on the shelf from left to right. If the sum of the prices of snacks in the basket will not exceed 300 yen, he immediately puts the checked snack into the basket. If the sum should exceed 300 yen, he tearfully skips that snack. After examining all the snacks in this manner to the right end, George heads to the checkout.

Given a list of the prices of the snacks in the store, compute how much money Greedy George will spend.

Figure A-1: The first dataset of Sample Input

입력

The input consists of multiple datasets, each in the following format. The number of datasets does not exceed 50.

n

a1 a2an

n (1 ≤ n ≤ 100) is the number of snacks sold in the candy store. ak (k = 1, …, n) is a positive integer less than or equal to 1000, meaning that the price of the k-th snack from the left is ak yen.

The end of the input is indicated by a line consisting of a zero.

출력

For each dataset, output in a line how many yen Greedy George will spend on the snacks.

제한

예제 입력 1

5
100 50 200 120 60
4
120 240 180 1
2
500 1000
6
2 3 5 7 11 13
0

예제 출력 1

270
300
0
41

힌트

출처

ICPC > Regionals > Asia Pacific > Japan > Japan Domestic Contest > 2024 Japan Domestic Contest A번

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

출처

대학교 대회

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

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