結果

問題 No.929 よくあるボールを移動するやつ
ユーザー ttr
提出日時 2020-02-02 19:51:06
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 120 ms / 2,000 ms
コード長 280 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 15,464 KB
最終ジャッジ日時 2024-09-18 21:22:10
合計ジャッジ時間 1,802 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

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