#P1178. 到天宫做客

到天宫做客

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 40004000. 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 NN, the number of days in the year 40004000 when I must stay on Earth.
The next NN 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 11 second).

2
3 8
12 2
63266

Hint

Sample Explanation (added on 2023.9.29)

The year 40004000 is a leap year with 366366 days, and February has 2929 days.

The longest continuous free period is from March 99 to December 11, a total of 268268 days. This corresponds to 86400×268÷366=63265.576326686400\times 268 \div 366=63265.57\approx 63266 seconds.

Translated by ChatGPT 5