Fast Forward
InterviewTime limit2sMemory limit1024 MB
For each start song in a circular playlist, count the ads that play when an ad can only follow a song and at least c seconds must pass between ads.
- Level
Medium6 of 10
- Topics
- Prefix sum, Greedy, Binary search, Array
- Solved
- No attempts yet
Problem
Gry has started to use the new Expify song streaming platform. Gry does not want to spend money, so Expify forces him to listen to advertisements. An advertisement can be played only after a song ends (it cannot be played in the middle of a song), and only if at least seconds have passed since the previous advertisement ended.
Gry has a circular playlist with songs. The duration of the -th song is seconds. Gry wants to minimize the number of advertisements, so he wants to know how many advertisements will play if he starts listening to the whole playlist from the -th song. The playlist stops after songs, wrapping around the circle as needed.
An advertisement plays right before Gry starts listening. That advertisement and the one that plays after the playlist stops are not counted.
Input
The first line contains and (, ). The second line contains the song durations ().
Output
For each starting song from 1 to , print the number of advertisements when Gry starts from the -th song. Print the answers on one line, separated by spaces.