P1167 Solving Problems
Description
As NOIP approaches, Xiao A realizes he has forgotten how to solve problems. Fortunately, there is still some time before the contest, so he decides to grind problems day and night from now on. That is, Xiao A will forgo sleep and solve problems twenty-four hours a day.
Today’s date (time) is yyyy year mm month dd day hh hour MM minute, and the exam time is yyyy2 year mm2 month dd2 day hh2 hour MM2 minute. He spends all the time in between solving problems. How many problems can he solve at most before the exam? Note: consider leap years.
Time is tight, so Xiao A cares only about quantity, not quality. Of course, some problems are easier and some are harder. Based on his experience, he can instantly tell how long it will take to solve any given problem, in minutes.
Given the Luogu Online Judge problem list, please choose as many problems as possible so that Xiao A can finish them before the contest.
Assume that from ancient times to the future, the calendar representation is the same as it is now.
Input Format
The first line contains an integer $N$, the number of Luogu Online Judge problems, $N≤5000$.
The next $N$ lines each contain one integer, the time required to solve that problem, in minutes ($ \le 10000$). (What the problems themselves are is not important, is it? `小A` has already solved $0$ problems.)
The next two lines are the current time and the contest time, respectively. The time format is: `yyyy-mm-dd-hh:MM`, for example: `2007-06-23-02:00`, using the $24$-hour system. Each day runs from 00:00 to 23:59, and years range from $0000$ to $9999$.
Output Format
One line containing a single integer: the maximum number of problems that can be solved before NOIP.
Explanation/Hint
Translated by ChatGPT 5