PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#BS0000149. Danh sách phát lặp vòng (Circular Playlist)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Danh sách phát lặp vòng (Circular Playlist)
Circular Playlist
Source: AtCoder
Version: Phuoc Hung OJ Extended
Problem Statement
A playlist consists of songs numbered through . Song lasts seconds. Songs play in order, and immediately after song finishes the playlist starts again at song . There is no pause between songs.
At exactly seconds after playback begins, determine the playing song and the time elapsed since its start. It is guaranteed that is not a song transition time.
Input
- The first line contains and the time in seconds.
- The second line contains integers in playback order.
Output
Print the -based song number followed by the elapsed seconds within that song.
Subtasks
- Subtask 1 (20 points): ; ; for all ; is not a song transition time.
- Subtask 2 (30 points): ; ; for all ; is not a song transition time.
- Subtask 3 (50 points): ; ; for all ; is not a song transition time.
Examples
Input
3 600
180 240 120
Output
1 60
Explanation
One complete cycle lasts seconds. At , exactly one cycle has ended and seconds have passed in the next cycle. Song lasts seconds, so song is playing with seconds elapsed; print 1 60.