結果
問題 |
No.929 よくあるボールを移動するやつ
|
ユーザー |
|
提出日時 | 2020-04-09 16:02:25 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 855 bytes |
コンパイル時間 | 97 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 15,428 KB |
最終ジャッジ日時 | 2024-09-13 12:02:05 |
合計ジャッジ時間 | 2,185 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 4 WA * 8 |
ソースコード
MOD = 10 ** 9 + 7 INF = 10 ** 10 import sys input = sys.stdin.readline sys.setrecursionlimit(100000000) dy = (-1,0,1,0) dx = (0,1,0,-1) from bisect import bisect_left,bisect_right from collections import deque def main(): n = int(input()) b = list(map(int,input().split())) ans = 0 idx1 = deque() idx2 = deque() for i in range(n): if b[i] == 1: continue elif b[i] == 0: if len(idx2) > 0: p = idx2.popleft() ans += i - p else: idx1.append(i) elif b[i] > 1: while len(idx1) and b[i] > 1: b[i] -= 1 p = idx1.popleft() ans += i - p for _ in range(b[i]): idx2.append(i) print(ans) if __name__ =='__main__': main()