P1178 Visiting the Heavenly Palace as a Guest
Description
One day I had a dream. I was honored to receive an invitation from Zhu Bajie to go to the Heavenly Palace and drink with him. I hesitated. One day in heaven equals one year on Earth! Of course, I am an idle person, and there are not many days in the year when I must stay on Earth. Therefore, I want to choose the longest continuous free period so that I can stay in heaven as long as possible. Remember, this year is the year $4000$. One day in heaven is also 24 hours, each hour 60 minutes, and each minute 60 seconds.
Input Format
The first line contains a non-negative integer $N$, the number of days in the year $4000$ when I must stay on Earth.
The next $N$ lines each contain two positive integers separated by a space, representing a date (month, day). The input is guaranteed to be valid, and dates are not repeated.
Output Format
A non-negative integer: the time spent in heaven (rounded to the nearest $1$ second).
Explanation/Hint
### Sample Explanation (added on 2023.9.29)
The year $4000$ is a leap year with $366$ days, and February has $29$ days.
The longest continuous free period is from March $9$ to December $1$, a total of $268$ days. This corresponds to $86400\times 268 \div 366=63265.57\approx 63266$ seconds.
Translated by ChatGPT 5