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

18331번 - Gold Rush 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 512 MB144806962.162%

문제

Again, Neverland has experienced a very bad economic condition over the past few months. The value of Oshloob, the national currency of Neverland, changes against one unit of gold very rapidly. People in Neverland, all wondering about their savings, are trying to exchange their savings with gold coins.

Dr. Predictman who is a data scientist, has obtained a prediction of the price (in Oshloobs) of a gold coin for the next n days based on the existing data over the past 40 years. He believes his prediction, and now he want to increase his savings based on it. He was wondering how much savings he has at the end of the n-th day assuming that he has c Oshloobs at the beginning of the first day. Since Dr. Predictman is not a programmer, he asks you to help to find his answer.

입력

The first line of the input contains two integers c (0 ⩽ c ⩽ 3000), Dr. Predictman’s initial savings in Oshloobs, and n (0 ⩽ n ⩽ 30), the period of his prediction. Each of the next following n lines contains an integer pi (1000 ⩽ pi ⩽ 2000) denoting the price of a gold coin at day i (1 ⩽ i ⩽ n) in Oshloobs.

출력

The output contains just an integer, which indicates the maximum savings he can obtain at the end of the n-th day assuming that Dr. Predictman exchanges all his remaining gold coins (if there is any) to Oshloobs at the end of the n-th day.

제한

예제 입력 1

1000 3
1000
1100
1200

예제 출력 1

1200

예제 입력 2

2000 4
1000
2000
1500
1800

예제 출력 2

4600

힌트

출처

ICPC > Regionals > Asia West Continent > Iran > Tehran Site 2019 B번

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

출처

대학교 대회

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

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