結果

問題 No.929 よくあるボールを移動するやつ
ユーザー ptotqptotq
提出日時 2019-11-22 23:59:32
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 281 bytes
コンパイル時間 95 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 18,260 KB
最終ジャッジ日時 2024-04-19 14:03:52
合計ジャッジ時間 2,030 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 33 ms
10,752 KB
testcase_02 AC 32 ms
10,752 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 AC 31 ms
10,880 KB
testcase_05 AC 28 ms
10,752 KB
testcase_06 AC 29 ms
10,752 KB
testcase_07 AC 72 ms
13,696 KB
testcase_08 AC 135 ms
18,260 KB
testcase_09 AC 138 ms
18,260 KB
testcase_10 AC 116 ms
11,988 KB
testcase_11 AC 114 ms
11,992 KB
testcase_12 AC 112 ms
12,124 KB
testcase_13 AC 110 ms
11,992 KB
testcase_14 AC 115 ms
11,988 KB
testcase_15 AC 115 ms
11,988 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
stack = []
for i, x in enumerate(map(int, input().split())):
    if x > 0:
        stack.append([i, x])
stack = stack[::-1]

ans = 0
for i in range(N):
    ans += abs(i - stack[-1][0])
    stack[-1][1] -= 1
    if stack[-1][1] == 0:
        stack.pop()

print(ans)
0