結果

問題 No.929 よくあるボールを移動するやつ
ユーザー 👑 KazunKazun
提出日時 2020-09-18 01:51:14
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 149 ms / 2,000 ms
コード長 303 bytes
コンパイル時間 273 ms
コンパイル使用メモリ 86,940 KB
実行使用メモリ 99,608 KB
最終ジャッジ日時 2023-09-04 08:15:23
合計ジャッジ時間 3,510 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
71,812 KB
testcase_01 AC 93 ms
71,672 KB
testcase_02 AC 96 ms
71,752 KB
testcase_03 AC 99 ms
71,456 KB
testcase_04 AC 92 ms
71,628 KB
testcase_05 AC 93 ms
71,700 KB
testcase_06 AC 92 ms
71,668 KB
testcase_07 AC 117 ms
82,152 KB
testcase_08 AC 149 ms
99,148 KB
testcase_09 AC 147 ms
99,200 KB
testcase_10 AC 139 ms
99,608 KB
testcase_11 AC 140 ms
99,160 KB
testcase_12 AC 129 ms
96,268 KB
testcase_13 AC 130 ms
96,208 KB
testcase_14 AC 125 ms
96,268 KB
testcase_15 AC 131 ms
96,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N=int(input())
B=list(map(int,input().split()))

C=[i for i in range(N) if not B[i]]
D=[i for i in range(N) if B[i]]

C=deque(C)
D=deque(D)

X=0
while C:
    while B[D[0]]==1:
        _=D.popleft()

    c=C.popleft()
    X+=abs(c-D[0])
    B[D[0]]-=1
    B[c]+=1

print(X)
0