Problem A
Jane Eyre
Anna wants to read the famous book Jane Eyre, but annoyingly its title is somewhat late in the alphabet. This is a problem, since Anna always reads books in alphabetical order; as soon as she finish reading a book, she immediately begins reading the next book in her possession which comes first according to ASCII-order.
To make matters even worse, Anna often receives new books as presents. Such books go into the pile of Anna’s unread books (she will finish the book she is currently reading even if the received book is earlier in the alphabet). If she receives one or more books at the exact same moment as she finishes another book, though, then she will pick her next book among both the books in her existing pile and the newly received books.
Given Anna’s pile of unread books and a schedule for at which points in time Anna’s friends will give her new books, can you figure out when she will finish reading Jane Eyre? Anna reads at a speed of one page per minute.
Input
On the first line are three non-negative integers
The next
Finally follows
Output
A single integer, the minute at which Anna finish reading Jane Eyre.
Sample Input 1 | Sample Output 1 |
---|---|
2 2 592 "Pride and Predjudice" 432 "Don Quixote" 863 863 "Great Gatsby" 218 1082 "Crime and Punishment" 545 |
1673 |