DWITE Online Computer Programming Contest, November 2008, Problem 4
Having acquired more (totally legitimate) music, than a tiny iPod Nano (it's a first generation, 2GB model, so that's plausible) can hold, and wanting to load music in full albums only, has posed quite a challenge for deciding on the playlists. To complicate the matters further, the disk space is shared with other data, so it fluctuates from time to time. This calls for some Computer Science.
The input will contain 5 sets of input. First line is the space available; an integer value . Second line is an integer , the number of albums in the library; . The next lines describe albums -- space required and total utility; both integer values, separated by space; . Each set is separated by a newline.
The output will contain 5 lines of output, each a sum of maximum utility that could fit given the associated input.
Note: Each album can appear only once in the playlist; though space-utility values are not guaranteed to be unique.
100 3 90 1000 50 400 50 400 100 3 90 1000 50 600 50 600 100 2 50 500 10 10
1000 1200 510