結果

問題 No.1438 Broken Drawers
ユーザー nephrologist
提出日時 2021-03-26 21:30:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 390 bytes
コンパイル時間 159 ms
コンパイル使用メモリ 82,224 KB
実行使用メモリ 109,168 KB
最終ジャッジ日時 2024-11-28 22:03:37
合計ジャッジ時間 3,363 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

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

memo = [-1] * n
for idx, a in enumerate(A):
    memo[a - 1] = idx
# print("memo", memo)

cnt = 0
used = [0] * n
dame = [0] * n
for i in range(n):
    idx = memo[i]
    if used[idx]:
        continue
    used[idx] = 1
    cnt += 1
    # print(cnt, i, idx)
    if idx - 1 >= 0:
        used[idx - 1] = 1
    # print(i, used)

print(cnt)
0