#abc281c. C - Circular Playlist

C - Circular Playlist

Score : 300300 points

问题陈述

我们有一个包含 NN 首歌曲的播放列表,编号为 1,,N1, \dots, N
ii 首歌曲持续时间为 AiA_i 秒。

当播放列表播放时,按照歌曲 11, 歌曲 22, \ldots, 歌曲 NN 的顺序依次播放。当歌曲 NN 结束时,播放列表会从歌曲 11 开始重新循环播放。在一首歌曲播放期间,下一首歌曲不会播放;当一首歌曲结束时,下一首歌曲会立即开始播放。

在播放列表开始播放后恰好 TT 秒时,正在播放的是哪首歌?同时,从该歌曲开始播放起已经过去了多少秒?
没有输入情况会在播放列表开始播放后恰好 TT 秒时切换歌曲。

以上为通义千问 qwen-max 翻译,仅供参考。

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.

Sample Input 1

3 600
180 240 120

Sample Output 1

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.

Sample Input 2

3 281
94 94 94

Sample Output 2

3 93

Sample Input 3

10 5678912340
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000

Sample Output 3

6 678912340

update @ 2024/3/10 11:48:12