結果

問題 No.929 よくあるボールを移動するやつ
ユーザー ttrttr
提出日時 2020-02-02 19:51:06
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 280 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 11,876 KB
実行使用メモリ 14,680 KB
最終ジャッジ日時 2023-10-19 01:24:31
合計ジャッジ時間 2,039 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,140 KB
testcase_01 AC 29 ms
10,140 KB
testcase_02 AC 29 ms
10,140 KB
testcase_03 AC 29 ms
10,140 KB
testcase_04 AC 30 ms
10,140 KB
testcase_05 AC 29 ms
10,140 KB
testcase_06 AC 29 ms
10,140 KB
testcase_07 AC 56 ms
11,088 KB
testcase_08 AC 92 ms
12,552 KB
testcase_09 AC 95 ms
12,552 KB
testcase_10 AC 115 ms
14,664 KB
testcase_11 AC 119 ms
14,680 KB
testcase_12 AC 114 ms
14,520 KB
testcase_13 AC 119 ms
14,664 KB
testcase_14 AC 120 ms
14,664 KB
testcase_15 AC 119 ms
14,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
N = int(input())
B = [int(b) for b in input().split()]

ans = 0
q = deque()
for i in range(N):
    if B[i] == 0:
        q.append(i)
for i in range(N):
    while B[i] > 1:
        B[i] -= 1
        t = q.popleft()
        ans += abs(t-i)

print(ans)
0