結果

問題 No.929 よくあるボールを移動するやつ
ユーザー 👑 H20H20
提出日時 2020-11-20 10:08:10
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 460 bytes
コンパイル時間 1,412 ms
コンパイル使用メモリ 86,712 KB
実行使用メモリ 89,716 KB
最終ジャッジ日時 2023-09-30 18:20:09
合計ジャッジ時間 7,938 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
71,140 KB
testcase_01 AC 77 ms
71,368 KB
testcase_02 AC 79 ms
71,240 KB
testcase_03 AC 78 ms
71,104 KB
testcase_04 AC 76 ms
71,100 KB
testcase_05 AC 76 ms
71,084 KB
testcase_06 AC 84 ms
75,648 KB
testcase_07 AC 107 ms
80,020 KB
testcase_08 AC 121 ms
89,196 KB
testcase_09 AC 121 ms
89,416 KB
testcase_10 AC 761 ms
89,052 KB
testcase_11 AC 1,067 ms
89,716 KB
testcase_12 AC 112 ms
89,100 KB
testcase_13 AC 100 ms
88,884 KB
testcase_14 TLE -
testcase_15 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
L = list(map(int, input().split()))
for i in range(N):
    L[i] -=1
ans = 0
for i in range(N):
    if L[i]<0:
        for j in range(i+1,N):
            if L[j]>0:
                L[i]=0
                L[j]-=1
                ans +=j-i
                break
    if L[i]>0:
        j = i+1
        while L[i]>0 and j<N:
            if L[j]<0:
                L[j]=0
                L[i]-=1
                ans +=j-i
            j+=1
print(ans)

0