| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 4 초 | 1024 MB | 19 | 12 | 12 | 70.588% |
It has been a long time since you moved to a different country and you have decided it is time to become a citizen. Your new country has a strict residency requirement for all applicants. To apply, you must have been physically present in the country for at least $d$ days per year, for the past $y$ consecutive years. These years are counted in 12ドル$-month periods backwards from the application date.
For this problem, assume that a calendar year has 12ドル$ months of 365ドル$ days, and each month has exactly the number of days below:
| month | 01 | 02 | 03 | 04 | 05 | 06 | 07 | 08 | 09 | 10 | 11 | 12 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| days | 31 | 28 | 31 | 30 | 31 | 30 | 31 | 31 | 30 | 31 | 30 | 31 |
For example, if you were to apply on 2024–09–19 you must have been in the country for at least $d$ days during the 12ドル$-month periods from 2023–09–19 to 2024–09–18, 2022–09–19 to 2023–09–18, and so on for $y$ such periods.
You have lived in the country for at least $y$ years, but having traveled a lot, you are not sure if you meet the residency requirement. Write a program that finds the earliest date you can submit your citizenship application given your travel history.
The first line contains three integers $n,ドル $y$ and $d$ (1ドル ≤ n ≤ 500,ドル 1ドル ≤ y ≤ 1,円 000,ドル 1ドル ≤ d ≤ 365$). You have been out of the country $n$ times and $y$ and $d$ specify the country’s residency requirement as described above.
Each of the following n lines contains two dates in the form YYYY-MM-DD (0000ドル ≤ $YYYY$ ≤ 5,円 000,ドル 01ドル ≤ $MM$ ≤ 12,ドル 01ドル ≤ $DD$ ≤ 31$). You have been out of the country between the two dates, inclusive. All dates in the input are sorted in increasing order. The only dates which may be equal are dates on the same line. All given dates are valid.
Output the earliest date on which you meet the residency requirement. The date must be after the last date of the input.
3 5 240 2022年02月28日 2022年10月01日 2022年11月11日 2022年11月11日 2023年12月30日 2024年01月01日
2024年05月31日
3 5 240 2011年11月11日 2012年12月12日 2022年02月28日 2022年10月01日 2025年01月01日 2025年06月30日
2028年02月26日