結果

問題 No.929 よくあるボールを移動するやつ
ユーザー 👑 H20H20
提出日時 2020-11-20 10:12:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 504 bytes
コンパイル時間 355 ms
コンパイル使用メモリ 87,120 KB
実行使用メモリ 89,472 KB
最終ジャッジ日時 2023-09-30 18:20:19
合計ジャッジ時間 3,027 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,096 KB
testcase_01 AC 76 ms
71,124 KB
testcase_02 AC 77 ms
71,256 KB
testcase_03 AC 77 ms
71,016 KB
testcase_04 AC 75 ms
71,044 KB
testcase_05 AC 76 ms
71,224 KB
testcase_06 AC 77 ms
70,984 KB
testcase_07 AC 114 ms
80,424 KB
testcase_08 AC 125 ms
89,472 KB
testcase_09 AC 123 ms
89,416 KB
testcase_10 AC 111 ms
89,244 KB
testcase_11 AC 107 ms
89,100 KB
testcase_12 AC 110 ms
88,756 KB
testcase_13 AC 98 ms
88,820 KB
testcase_14 AC 101 ms
88,956 KB
testcase_15 AC 105 ms
88,832 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
L = list(map(int, input().split()))
for i in range(N):
    L[i] -=1
ans = 0
temp = 0
for i in range(N):
    if L[i]<0:
        for j in range(max(i+1,temp),N):
            if L[j]>0:
                L[i]=0
                L[j]-=1
                ans +=j-i
                temp = j
                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