atcoder#ABC281C. [ABC281C] Circular Playlist

[ABC281C] Circular Playlist

Score : 300300 points

Problem Statement

We have a playlist with NN songs numbered 1,,N1, \dots, N. Song ii lasts AiA_i seconds.

When the playlist is played, song 11, song 22, \ldots, and song NN play in this order. When song NN ends, the playlist repeats itself, starting from song 11 again. While a song is playing, the next song does not play; when a song ends, the next song starts immediately.

At exactly TT seconds after the playlist starts playing, which song is playing? Also, how many seconds have passed since the start of that song? There is no input where the playlist changes songs at exactly TT seconds after it starts playing.

Constraints

  • 1N1051 \leq N \leq 10^5
  • 1T10181 \leq T \leq 10^{18}
  • 1Ai1091 \leq A_i \leq 10^9
  • The playlist does not change songs at exactly TT seconds after it starts playing.
  • All values in the input are integers.

Input

The input is given from Standard Input in the following format:

NN TT

A1A_1 \ldots ANA_N

Output

Print an integer representing the song that is playing at exactly TT seconds after the playlist starts playing, and an integer representing the number of seconds that have passed since the start of that song, separated by a space.

3 600
180 240 120
1 60

When the playlist is played, the following happens. (Assume that it starts playing at time 00.)

  • From time 00 to time 180180, song 11 plays.
  • From time 180180 to time 420420, song 22 plays.
  • From time 420420 to time 540540, song 33 plays.
  • From time 540540 to time 720720, song 11 plays.
  • From time 720720 to time 960960, song 22 plays.
  • \qquad\vdots

At time 600600, song 11 is playing, and 6060 seconds have passed since the start of that song.

3 281
94 94 94
3 93
10 5678912340
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000
6 678912340