Logo
(追記) (追記ここまで)

32422번 - Citizenship 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
4 초 1024 MB19121270.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.

제한

예제 입력 1

3 5 240
2022年02月28日 2022年10月01日
2022年11月11日 2022年11月11日
2023年12月30日 2024年01月01日

예제 출력 1

2024年05月31日

예제 입력 2

3 5 240
2011年11月11日 2012年12月12日
2022年02月28日 2022年10月01日
2025年01月01日 2025年06月30日

예제 출력 2

2028年02月26日

힌트

출처

ICPC > World Finals > ICPC World Finals 2024 C번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /