結果

問題 No.929 よくあるボールを移動するやつ
ユーザー komkompikomkompi
提出日時 2020-03-29 10:26:10
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 91 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,628 KB
実行使用メモリ 12,548 KB
最終ジャッジ日時 2023-08-30 18:39:04
合計ジャッジ時間 2,043 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
7,680 KB
testcase_01 AC 15 ms
7,844 KB
testcase_02 AC 16 ms
7,920 KB
testcase_03 AC 15 ms
7,764 KB
testcase_04 AC 15 ms
7,796 KB
testcase_05 AC 16 ms
7,836 KB
testcase_06 AC 16 ms
7,756 KB
testcase_07 AC 42 ms
8,864 KB
testcase_08 AC 82 ms
10,012 KB
testcase_09 AC 81 ms
9,936 KB
testcase_10 AC 85 ms
9,960 KB
testcase_11 AC 87 ms
10,004 KB
testcase_12 AC 74 ms
10,012 KB
testcase_13 AC 76 ms
9,972 KB
testcase_14 AC 91 ms
12,548 KB
testcase_15 AC 82 ms
10,868 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 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