結果

問題 No.1104 オンライン点呼
ユーザー gew1fw
提出日時 2025-06-12 14:17:47
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 734 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 82,532 KB
実行使用メモリ 108,632 KB
最終ジャッジ日時 2025-06-12 14:17:53
合計ジャッジ時間 3,289 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    input = sys.stdin.read().split()
    idx = 0
    N = int(input[idx])
    idx += 1
    K = int(input[idx])
    idx += 1
    
    A = list(map(int, input[idx:idx+N]))
    idx += N
    B = list(map(int, input[idx:idx+N]))
    idx += N
    
    if N == 1:
        print(0)
        return
    
    prev_prev = 0  # S[1]
    prev = prev_prev + A[0] + B[1]  # S[2]
    max_time = max(prev_prev, prev)
    
    for j in range(3, N+1):
        t1 = prev + A[j-2] + B[j-1]
        t2 = prev_prev + A[j-3] + B[j-1]
        current = min(t1, t2 + K)
        if current > max_time:
            max_time = current
        prev_prev, prev = prev, current
    
    print(max_time)

if __name__ == "__main__":
    main()
0