結果
問題 | No.929 よくあるボールを移動するやつ |
ユーザー | O2MT |
提出日時 | 2020-12-08 16:13:56 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 294 ms / 2,000 ms |
コード長 | 473 bytes |
コンパイル時間 | 419 ms |
コンパイル使用メモリ | 11,872 KB |
実行使用メモリ | 15,788 KB |
最終ジャッジ日時 | 2023-10-17 17:19:17 |
合計ジャッジ時間 | 3,345 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 30 ms
10,216 KB |
testcase_01 | AC | 30 ms
10,216 KB |
testcase_02 | AC | 29 ms
10,216 KB |
testcase_03 | AC | 30 ms
10,216 KB |
testcase_04 | AC | 29 ms
10,216 KB |
testcase_05 | AC | 29 ms
10,216 KB |
testcase_06 | AC | 29 ms
10,216 KB |
testcase_07 | AC | 105 ms
12,292 KB |
testcase_08 | AC | 235 ms
15,788 KB |
testcase_09 | AC | 231 ms
15,788 KB |
testcase_10 | AC | 223 ms
14,736 KB |
testcase_11 | AC | 260 ms
14,752 KB |
testcase_12 | AC | 294 ms
15,020 KB |
testcase_13 | AC | 192 ms
14,736 KB |
testcase_14 | AC | 194 ms
14,736 KB |
testcase_15 | AC | 193 ms
14,736 KB |
ソースコード
from heapq import * N = int(input()) B = list(map(int,input().split())) zero = [] stock = [] count = 0 for i in range(N): if B[i] == 0: heappush(zero,i) elif B[i] == 1: pass else: heappush(stock,(i,B[i])) while zero != [] and stock != []: z = heappop(zero) s,i = heappop(stock) if i > 1: heappush(stock,(s,i-1)) else: s,i = heappop(stock) heappush(stock,(s,i-1)) count += abs(z-s) print(count)