結果

問題 No.929 よくあるボールを移動するやつ
ユーザー 12354865271235486527
提出日時 2020-01-14 12:35:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 232 bytes
コンパイル時間 92 ms
コンパイル使用メモリ 10,708 KB
実行使用メモリ 14,600 KB
最終ジャッジ日時 2023-08-26 02:39:15
合計ジャッジ時間 2,018 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,872 KB
testcase_01 AC 15 ms
7,788 KB
testcase_02 AC 16 ms
7,744 KB
testcase_03 AC 16 ms
7,808 KB
testcase_04 AC 15 ms
7,752 KB
testcase_05 AC 16 ms
7,908 KB
testcase_06 AC 15 ms
7,884 KB
testcase_07 AC 37 ms
9,744 KB
testcase_08 AC 73 ms
12,016 KB
testcase_09 AC 71 ms
12,000 KB
testcase_10 AC 80 ms
13,768 KB
testcase_11 AC 81 ms
13,584 KB
testcase_12 AC 78 ms
13,604 KB
testcase_13 AC 78 ms
13,580 KB
testcase_14 AC 80 ms
14,600 KB
testcase_15 AC 79 ms
13,736 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

_ = int(input())
B = map(int, input().split())
P = []
Z = []
ans = 0
for i, n in enumerate(B):
    if n == 0:
        Z.append(i)
    elif n > 1:
        P.extend([i] * (n-1))
for z, p in zip(Z, P):
    ans += abs(z - p)
print(ans)
0