結果

問題 No.929 よくあるボールを移動するやつ
ユーザー stngstng
提出日時 2022-08-15 10:32:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 67 ms / 2,000 ms
コード長 362 bytes
コンパイル時間 217 ms
コンパイル使用メモリ 82,976 KB
実行使用メモリ 80,596 KB
最終ジャッジ日時 2024-04-09 22:37:07
合計ジャッジ時間 1,967 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
52,684 KB
testcase_01 AC 37 ms
52,072 KB
testcase_02 AC 37 ms
52,832 KB
testcase_03 AC 38 ms
52,404 KB
testcase_04 AC 38 ms
52,228 KB
testcase_05 AC 38 ms
52,464 KB
testcase_06 AC 37 ms
52,620 KB
testcase_07 AC 62 ms
68,868 KB
testcase_08 AC 67 ms
78,332 KB
testcase_09 AC 67 ms
78,272 KB
testcase_10 AC 64 ms
78,532 KB
testcase_11 AC 66 ms
80,596 KB
testcase_12 AC 63 ms
75,636 KB
testcase_13 AC 56 ms
72,120 KB
testcase_14 AC 58 ms
72,680 KB
testcase_15 AC 59 ms
74,196 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
b = [int(i) for i in input().split()]

now = 0
ans = 0
for i in range(n):
    if b[i] == 0:
        for j in range(n):
            if b[now] >= 2:
                b[now] -= 1
                b[i] = 1
                #print(now-i,"now")
                ans += abs(now-i)
                break
            else:
                now += 1
print(ans)
0