結果

問題 No.3099 Parentheses Decomposition
ユーザー gew1fw
提出日時 2025-06-12 18:26:02
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,141 bytes
コンパイル時間 175 ms
コンパイル使用メモリ 82,552 KB
実行使用メモリ 66,936 KB
最終ジャッジ日時 2025-06-12 18:26:28
合計ジャッジ時間 2,433 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 4
other RE * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

def calculate_night_time(a, b):
    time = 0.0
    # Check overlap with 18:00 to 24:00
    overlap_start = max(a, 18)
    overlap_end = min(b, 24)
    if overlap_start < overlap_end:
        time += overlap_end - overlap_start
    # Check overlap with 00:00 to 06:00
    overlap_start = max(a, 0)
    overlap_end = min(b, 6)
    if overlap_start < overlap_end:
        time += overlap_end - overlap_start
    return time

T, S, D = map(int, input().split())
t = D / S

full_days = t // 24
remaining_time = t % 24

S_current = T  # Start time for the remaining period (mod 24 is handled implicitly)
E = S_current + remaining_time

remaining_night = 0.0

if E > 24:
    part1_start = S_current
    part1_end = 24
    part2_start = 0
    part2_end = E - 24
    remaining_night += calculate_night_time(part1_start, part1_end)
    remaining_night += calculate_night_time(part2_start, part2_end)
else:
    part1_start = S_current
    part1_end = E
    remaining_night += calculate_night_time(part1_start, part1_end)

total_night = full_days * 12 + remaining_night

# Ensure the output has sufficient precision
print("{0:.15f}".format(total_night))
0