提出 #73488628


ソースコード 拡げる

from collections import deque
for _ in range(int(input())):
    N,D = map(int,input().split())
    A = list(map(int,input().split()))
    B = list(map(int,input().split()))
    q = deque()
    ans = 0
    for i in range(1,N+1):
        q.append([i,A[i-1]])
        ans += A[i-1]
        X = B[i-1]
        while X > 0:
            d,e = q[0]
            Y = min(e,X)
            e -= Y
            X -= Y
            ans -= Y
            if e == 0:
                q.popleft()
            else:
                q[0][1] = e
        while q and q[0][0] <= i-D:
            ans -= q[0][1]
            q.popleft()
    print(ans)

提出情報

提出日時
問題 C - Omelette Restaurant
ユーザ glaceon1020
言語 Python (PyPy 3.11-v7.3.20)
得点 300
コード長 648 Byte
結果 AC
実行時間 887 ms
メモリ 159204 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 300 / 300
結果
AC × 1
AC × 30
セット名 テストケース
Sample example_00.txt
All example_00.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 66 ms 93756 KiB
hand_00.txt AC 125 ms 158624 KiB
hand_01.txt AC 124 ms 159200 KiB
hand_02.txt AC 116 ms 159048 KiB
hand_03.txt AC 120 ms 159056 KiB
hand_04.txt AC 119 ms 159204 KiB
hand_05.txt AC 887 ms 109776 KiB
hand_06.txt AC 126 ms 158660 KiB
hand_07.txt AC 520 ms 127236 KiB
hand_08.txt AC 67 ms 93876 KiB
random_00.txt AC 288 ms 110924 KiB
random_01.txt AC 276 ms 110644 KiB
random_02.txt AC 279 ms 110484 KiB
random_03.txt AC 286 ms 111044 KiB
random_04.txt AC 284 ms 110860 KiB
random_05.txt AC 115 ms 109744 KiB
random_06.txt AC 110 ms 109328 KiB
random_07.txt AC 113 ms 109532 KiB
random_08.txt AC 117 ms 110316 KiB
random_09.txt AC 112 ms 109812 KiB
random_10.txt AC 129 ms 158268 KiB
random_11.txt AC 126 ms 158488 KiB
random_12.txt AC 129 ms 158060 KiB
random_13.txt AC 131 ms 158360 KiB
random_14.txt AC 125 ms 158336 KiB
random_15.txt AC 125 ms 158460 KiB
random_16.txt AC 126 ms 158544 KiB
random_17.txt AC 130 ms 158288 KiB
random_18.txt AC 124 ms 158428 KiB
random_19.txt AC 130 ms 158752 KiB