結果

問題 No.1687 What the Heck?
ユーザー 👑 H20H20
提出日時 2021-09-24 21:37:03
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 484 bytes
コンパイル時間 459 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 110,668 KB
最終ジャッジ日時 2023-09-18 20:53:09
合計ジャッジ時間 3,452 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
71,340 KB
testcase_01 AC 74 ms
71,292 KB
testcase_02 WA -
testcase_03 AC 72 ms
71,196 KB
testcase_04 AC 74 ms
71,356 KB
testcase_05 AC 75 ms
71,068 KB
testcase_06 AC 74 ms
71,244 KB
testcase_07 AC 98 ms
86,712 KB
testcase_08 AC 106 ms
91,884 KB
testcase_09 WA -
testcase_10 AC 93 ms
82,748 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 131 ms
110,440 KB
testcase_14 AC 125 ms
110,156 KB
testcase_15 AC 125 ms
110,284 KB
testcase_16 AC 126 ms
110,132 KB
testcase_17 AC 84 ms
76,352 KB
testcase_18 AC 126 ms
110,176 KB
testcase_19 AC 85 ms
76,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
P = list(map(int, input().split()))
P = P[::-1]
L = [0]*(N+1)
ans = 0
mi = 1
for i in range(N):
    p = P[i]
    for j in range(p+1,N+1):
        if L[j]==0:
            L[j]=1
            ans += N-i
            break
    else:
        if L[p]==0:
            L[p]=1
        else:
            for j in range(mi,N+1):
                if L[j]==0:
                    mi=j+1
                    L[j]=1

                    ans -= N-i
                    break
print(ans)
0