You have inherited the publishing rights to N songs by the Raucous Rockers. You want to release a boxed set of D compact disks, each of which can hold at most M minutes of music. To satisfy the fans, you must put the songs in chronological order, but you can omit songs (regardless of when they were recorded) if necessary. Of course, no song can be split across a disk. Given a list of the song lengths in chronological order, your task is to figure out the maximum number of songs that can be recorded on the set of disks subject to these criteria.
The input will contain one or more pairs of lines. The first line will contain N, M, and D, separated by blanks. The second line will contain the song lengths in chronological order, separated by blanks. By an amazing coincidence the length of each song is an exact multiple of one minute, so the lengths are in minutes. No song is longer than M minutes. For each pair of input lines, output a single line containing the maximum number of songs that can be recorded.
Input must be read from the file "prob29.in", and output must be
written to the file "prob29.out". All output to the screen will be
ignored.
<BOF> 4 60 1 5 17 4 6 13 30 3 3 5 15 8 14 3 20 4 8 12 2 3 2 9 15 4 7 9 10 6 7 11 9 7 7 <EOF>
4 12 6
Dr. Eric Shade