結果

問題 No.3083 One Two
ユーザー gew1fw
提出日時 2025-06-12 13:23:53
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,614 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 82,688 KB
実行使用メモリ 67,072 KB
最終ジャッジ日時 2025-06-12 13:29:14
合計ジャッジ時間 1,673 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 7
権限があれば一括ダウンロードができます

ソースコード

diff #

import datetime

def is_leap(year):
    return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0)

def calculate_days_after_X(m_x, d_x, leap):
    month_days = [
        (1, 31), (2, 29 if leap else 28), (3, 31),
        (4, 30), (5, 31), (6, 30),
        (7, 31), (8, 31), (9, 30),
        (10, 31), (11, 30), (12, 31)
    ]
    current_month = m_x
    current_day = d_x + 1
    if current_day > month_days[current_month - 1][1]:
        current_month += 1
        current_day = 1
    if current_month > 12:
        current_month = 1
    days = 0
    while True:
        if current_month == 4 and current_day == 1:
            days += 1
            break
        days += 1
        current_day += 1
        if current_day > month_days[current_month - 1][1]:
            current_month += 1
            current_day = 1
            if current_month > 12:
                current_month = 1
    return days

def is_in_range(m, d):
    if (m > 4) or (m == 4 and d >= 2):
        return True
    elif m < 4:
        if (m, d) <= (4, 1):
            return True
    return False

Y, N, D = map(int, input().split())

start_date = datetime.date(Y, 4, 1) + datetime.timedelta(days=D)
m_x = start_date.month
d_x = start_date.day

year_ref = Y - 11  # Y-12+1 = Y-11
leap = is_leap(year_ref)

in_range = is_in_range(m_x, d_x)

if in_range:
    days_after = calculate_days_after_X(m_x, d_x, leap)
else:
    if (m_x, d_x) <= (4, 1):
        days_after = 365
    else:
        days_after = 0

days_before = 365 - days_after

max_count = min(days_after, N)
min_count = max(0, N - days_before)

print(f"{min_count} {max_count}")
0