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

21623번 - Game 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 512 MB251908537.611%

문제

Petya was bored during the lockdown, so he came up with a new single player game that uses random numbers generator.

The game consists of several rounds, each round consists of one or more moves. Throughout the game Petya keeps track of his current score.

At the beginning of every round Petya has the score equal to $n$. Every move the generator outputs a non-negative integer and Petya tries to subtract it from his current score. If the result is non-negative, he changes his score to the result of the subtracation, otherwise, the result is ignored and the score does not change. For example, if the current score is 3ドル,ドル and the generator outputs 2ドル,ドル Petya does the subtraction and the score changes to 1ドル$. If the generator output is 5ドル,ドル the result is ignored and the score remains 3ドル$.

If the score after the current move is 0ドル,ドル the round ends, and at the beginning of the next move Petya is back to the score of $n$.

Lockdown had ended long ago, but Petya has suddenly came across a sheet of paper that contains a sequence of $k$ integers ---generator output throughout the game. The boy wonders how many rounds had he played and what was his current score when he stopped the game. Help him find it out using the notes on the sheet.

입력

The first line of input contains two integers: $k$ --- the number of moves Petya made, $n$ --- the score at the beginning of every round (1ドル \le k \le 100,000円,ドル 1ドル \le n \le 10^8$).

The second line contains $k$ integers --- output of random numbers generator (0ドル \le a_i \le 10^8$).

출력

The first line must contain one integer --- the amount of played rounds.

The second line must contain one integer --- the score at the end of the game.

If the last move of the game had ended the round, Petya didn't not begin a new round and his score was 0ドル$.

제한

예제 입력 1

4 3
1 2 4 1

예제 출력 1

1
2

힌트

출처

Olympiad > Russian Olympiad in Informatics > Russia High School Programming Contest > Russia High School Programming Contest 2020 C번

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

출처

대학교 대회

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

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