• [H] If You Do Not Leave Me

  • 时间限制: 2000 ms 内存限制: 262144 K
  • 问题描述
  • 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.

  • 输入
  • The first line includes three integers N, M, K (1 <= N, M <= 100, 1 <= K <= 10). N means there are N people (number 1 to N) to borrow books and M means there are M books (number 1 to M) in the library.
    Follow next N lines, i-th line indicates i-th person's hobby. For i-th line, first give two integers S, P (1 <= S, P <= 100), which means from the day S the i-th person is interested in P books, follow P integers indicate i-th person’s favorite books.
  • 输出
  • Output an integer indicates maximum value the sense of social well-being increase.
    If the value is 0, output “If you do not leave me, I will by your side until the life end!” (not including quotes).
  • 样例输入
  • 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  
    数据已加强
  • 操作

显示春菜