Ushered in the Lantern Festival full with super scholars, all seats are occupied in the library. Well goes a saying, a beautiful girl is in the book. The library is a good place aiming to arouse the sense of social well-being. Having browsed plenty of books people can increase this kind of sense. As a high-level ACMer, you ought to put you intelligence to use and help all human being improve the sense of social well-being.
Show time!
Here comes students to borrow books one after another in the library. Each student comes once at most, and every time they will tell the librarian what kinds of books they need and next K days they will read it. (after K days they won't read books any more ).
Each kind of book only have one in the library.
Each student need one day to read one book.
Each student can increase one point in the sense of social well-being after reading one book.
Absolutely, each student will return the book after reading at once, and it won’t influence lending books the second day.
Your assignment is to distribute each book reasonably to increase social well-being sharply and to find out maximum value the sense increase.
3 2 2 1 1 1 2 2 1 2 3 2 1 2
5
Note to the sample. Initially the first day is number 1. First day, Person 1 borrows 1-th book and reads it, then he return it at the first day night. Second day, person 2 borrows 1-th book and read it at second day. Third day, person 2 borrows 2-th book and person 3 borrows 1-th book. Fourth day, person 3 borrows 2-th book. So the answer: 1 + 1 + 2 + 1 = 5 .
九野 @NIT 数据已加强