結果

問題 No.929 よくあるボールを移動するやつ
ユーザー titiatitia
提出日時 2019-11-22 22:21:16
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 395 bytes
コンパイル時間 121 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 18,048 KB
最終ジャッジ日時 2024-04-19 11:50:29
合計ジャッジ時間 2,127 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,752 KB
testcase_01 AC 31 ms
10,752 KB
testcase_02 AC 29 ms
10,880 KB
testcase_03 AC 29 ms
10,752 KB
testcase_04 AC 29 ms
10,752 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 136 ms
12,764 KB
testcase_14 AC 139 ms
12,636 KB
testcase_15 AC 139 ms
12,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
B=list(map(int,input().split()))

from collections import deque
Q=deque()

for i in range(N):
    if B[i]!=0:
        Q.append([i,B[i]])

ANS=0
for i in range(N):
    if B[i]!=0:
        continue
    else:
        ANS+=abs(Q[0][0]-i)
        Q[0][1]-=1
        B[i]+=1
        B[Q[0][0]]-=1
        
        if Q[0][1]==0:
            Q.popleft()

    #print(i,ANS,Q)

print(ANS)
0