Uni's Letter Writing
InterviewTime limit1sMemory limit1024 MB
Given each friend's enlistment and discharge months, find the earliest month when the most friends are in the military.
- Level
Easy3 of 10
- Topics
- Prefix sum, Array
- Solved
- No attempts yet
Problem
Uni, who graduated from an all-boys middle and high school, has many friends in the military around them. Uni wants to write letters to the friends who are serving.
But Uni finds it tiresome to write to so many friends, so Uni decides to write letters for one month only.
If Uni writes only during one month, some friends will not receive any letters while in the military. So Uni wants to find the one month when the most friends are in the military.
Uni is not good at figuring things out, so help Uni find when to write the letters.
Input
The first line contains the number of Uni's friends who enter the military. ()
From the second line, each of the next lines gives the enlistment month and the discharge month of a friend in the form YYYY-MM.
YYYY is the year, an integer from to .
MM is the month, an integer from to . A single-digit month is written with a leading 0.
The enlistment month and the discharge month are both months in which the friend is in the military. The discharge month is always the same as or later than the enlistment month.
Output
Print the time when Uni should write letters in the form YYYY-MM. If there are several such times, print the earliest one.