結果

問題 No.1438 Broken Drawers
コンテスト
ユーザー nephrologist
提出日時 2021-03-26 21:30:54
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 63 ms / 2,000 ms
+ 263µs
コード長 390 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 69 ms
コンパイル使用メモリ 81,100 KB
実行使用メモリ 111,372 KB
最終ジャッジ日時 2026-10-01 14:51:38
合計ジャッジ時間 4,073 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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