|
Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб. Question by Ibrahim Mesecan.
Reading Book
Your sister has a reading competition in
her school. But she has difficulties in reading.
She prefers the books which has more pictures in
it. Before she starts reading she takes notes
of the pages with pictures. If there are several pictures
consecutively, she becomes happy. If there are many pages
without pictures, it's a difficult part to read.
Question:
Write a program that reads page number of pictures
for n books and defines the book which has a picture
after the most number of pages.
Input specification
You will be given an integer in the beginning:
the number of books (k where 1 ≤ k ≤ 4,000 ).
Then in the following
k lines, you will be given several integers (page numbers
of pictures) where each number is between 1 and
30,000 (books like encyclopedia :) ending with a
negative number. After the negative number you will
be given total number of pages of the book.
The books might have at most 500 pictures.
Output specification
Show the id of the book which contains the
most difficult part. (The most number of
consecutive pages without picture.)
Note: 1) Page ids start from 1
2) If there are several books with the same
max number of consecutive pages show the id of
the first book.
Sample Input I
3
5 4 7 -2 10
2 15 7 9 3 -2 20
2 7 4 8 -2 10
|
Sample Output I
2
|
Explanation:
-
The first book has
10 pages and it has the pictures on pages 4, 5, and 7.
There are 3 consecutive pages at most without any picture.
- The second book has 20 pages and it has the
pictures on pages 2, 3, 7, 9 and 15. There are at most 5
consecutive pages without any picture.
-
The third book has 10 pages and it has the
pictures on pages 2, 4, 7, and 8. There are at most 2
consecutive pages without any picture.
As a result, the second book has the most number of
consecutive pages without any picture.
Для отправки решений необходимо выполнить вход.
|