結果

問題 No.929 よくあるボールを移動するやつ
コンテスト
ユーザー komkompi
提出日時 2020-03-29 10:26:10
言語 Python3
(3.15.2 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 66 ms / 2,000 ms
+ 407µs
コード長 445 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 54 ms
コンパイル使用メモリ 15,104 KB
実行使用メモリ 15,432 KB
最終ジャッジ日時 2026-10-10 06:44:25
合計ジャッジ時間 1,897 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# coding: utf-8
# Your code here!
N=int(input())

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

empty=[]
rem=[]

ans=0
for i in range(len(B)):
    if B[i]==0:
        if len(rem)==0:
            empty.append(i)
        else:
            ans+=(i-rem.pop(-1))
            
    else:
        while B[i]>1 and empty:
            ans+=(i-empty.pop(-1))
            B[i]-=1
        
        for j in range(B[i]-1):
            rem.append(i)
        
print(ans)


0