P16291 [Lanqiao Cup 2026 NOI Qualifier Java A Group] Consecutive Check-ins

Description

Xiaoming is a self-disciplined programmer. He uses a learning check-in app every day to record his study progress. The app records the date of each check-in. Now Xiaoming wants to find his longest streak of consecutive check-in days. A consecutive check-in means that there is a check-in record on every day within a continuous range of days. For example, if Xiaoming checked in on 2026-01-01, 2026-01-02, and 2026-01-03, then this is a streak of $3$ consecutive days. Given Xiaoming's check-in records (a number of dates), compute the maximum number of consecutive check-in days. Note: If none of the check-in dates are adjacent, then the longest consecutive check-in days is $1$. That is, a single day is also considered a streak of $1$ day. Note: The check-in records may contain duplicates (multiple check-ins on the same day). Multiple check-ins on the same day count as one day only.

Input Format

The first line contains an integer $N$, representing the number of check-in records. The next $N$ lines each contain a date in the format YYYY-MM-DD (year-month-day).

Output Format

Output one integer, representing the maximum number of consecutive check-in days.

Explanation/Hint

### Sample Explanation 1 After removing duplicates, Xiaoming's check-in dates are: 2026-01-01, 2026-01-02, 2026-01-03, 2026-01-05, 2026-01-06, 2026-01-10. Among them: - 2026-01-01 to 2026-01-03 are $3$ consecutive days. - 2026-01-05 to 2026-01-06 are $2$ consecutive days. - 2026-01-10 is a single streak of $1$ day. Therefore, the longest consecutive check-in days is $3$. ### Sample Explanation 2 These $5$ days are consecutive dates across two years, from December 30, 2025 to January 3, 2026, for a total of $5$ consecutive check-in days. ### Constraints and Evaluation Rules For all testdata: - $1 \le N \le 100000$. - Date range: 2000-01-01 to 2099-12-31. - All dates are guaranteed to be valid (including leap years). - Dates may be given in any order and may contain duplicates. | Testdata Percentage | Data Size | |:-------------------:|:---------:| | 30% | $1 \le N \le 100$ | | 60% | $1 \le N \le 10000$ | | 100% | $1 \le N \le 100000$ | Translated by ChatGPT 5