結果

問題 No.929 よくあるボールを移動するやつ
ユーザー TS_KAsTS_KAs
提出日時 2019-11-23 01:15:09
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 297 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 82,428 KB
実行使用メモリ 93,184 KB
最終ジャッジ日時 2024-04-19 14:21:21
合計ジャッジ時間 2,072 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,760 KB
testcase_01 AC 38 ms
53,760 KB
testcase_02 AC 38 ms
53,504 KB
testcase_03 AC 36 ms
53,248 KB
testcase_04 AC 38 ms
53,888 KB
testcase_05 AC 37 ms
53,888 KB
testcase_06 AC 37 ms
53,632 KB
testcase_07 AC 58 ms
75,776 KB
testcase_08 AC 77 ms
92,288 KB
testcase_09 AC 79 ms
92,288 KB
testcase_10 AC 71 ms
92,544 KB
testcase_11 AC 71 ms
93,184 KB
testcase_12 AC 67 ms
92,416 KB
testcase_13 AC 62 ms
91,264 KB
testcase_14 AC 62 ms
91,008 KB
testcase_15 AC 66 ms
92,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N = int(input())
B = list(map(int, input().split()))
Zero = []
for i in range(N):
    if B[i] == 0:
        Zero.append(i)
ans = 0
q = deque(Zero)
for i in range(N):
    if B[i] >= 2:
        for j in range(B[i]-1):
            ans += abs(i - q.popleft())
print(ans)
0