#C10625. Movie Marathon Timing
Movie Marathon Timing
Movie Marathon Timing
In a movie marathon, a sequence of movies is played back-to-back. Each movie has a given duration in minutes. Given the total number of movies, the elapsed time since the marathon started, and the duration of each movie, determine which movie is currently being watched and the number of minutes that have passed in that movie.
More formally, let the movies be numbered from 1 to \(n\) and let \(d_1, d_2, \dots, d_n\) be their respective durations. You are also given an integer \(t\), representing the number of minutes elapsed since the beginning of the marathon. Your task is to find the smallest index \(i\) such that \[ \sum_{j=1}^{i} d_j > t, \] which means that the \(i\)-th movie is currently playing. The number of minutes passed in the current movie is \(t - \sum_{j=1}^{i-1} d_j\). If \(t\) is exactly equal to the end of a movie, then the next movie is considered to have just started (if there is one).
inputFormat
The input is read from standard input and consists of two lines:
- The first line contains two integers \(n\) and \(t\), where \(n\) (\(1 \leq n\)) is the number of movies and \(t\) (\(0 \leq t\)) is the total elapsed time in minutes.
- The second line contains \(n\) space-separated integers \(d_1, d_2, \dots, d_n\), where each \(d_i\) is the duration of the \(i\)-th movie in minutes.
outputFormat
Output to standard output two space-separated integers: the 1-indexed identifier of the current movie and the number of minutes passed since that movie started.
## sample4 150
50 40 70 120
3 60