結果

問題 No.1438 Broken Drawers
コンテスト
ユーザー ygd.
提出日時 2021-03-26 21:29:34
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 144 ms / 2,000 ms
+ 296µs
コード長 416 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 79 ms
コンパイル使用メモリ 64,672 KB
実行使用メモリ 95,216 KB
最終ジャッジ日時 2026-10-15 13:15:42
合計ジャッジ時間 5,537 ms
ジャッジサーバーID
(参考情報)
judge5_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
A = [a-1 for a in A]
dic = defaultdict(int)
for i,x in enumerate(A):
    dic[x] = i
B = sorted(A)
used = [0]*N
ans = 0
for i, x in enumerate(B):
    if used[x] == 1: continue
    ans += 1
    used[x] = 1
    shita = dic[x] - 1
    #print(A[shita])
    if shita >= 0 and used[A[shita]] == 0:
        used[A[shita]] = 1
print(ans)
0