結果

問題 No.929 よくあるボールを移動するやつ
ユーザー hedwig100hedwig100
提出日時 2020-04-09 16:02:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 855 bytes
コンパイル時間 449 ms
コンパイル使用メモリ 10,840 KB
実行使用メモリ 13,116 KB
最終ジャッジ日時 2023-10-11 13:16:31
合計ジャッジ時間 2,389 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,732 KB
testcase_01 AC 19 ms
8,556 KB
testcase_02 AC 19 ms
8,664 KB
testcase_03 AC 19 ms
8,600 KB
testcase_04 AC 19 ms
8,520 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 57 ms
10,348 KB
testcase_14 AC 66 ms
13,116 KB
testcase_15 AC 60 ms
11,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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()  
0