結果
| 問題 | No.1438 Broken Drawers |
| コンテスト | |
| ユーザー |
ygd.
|
| 提出日時 | 2021-03-26 21:29:34 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 150 ms / 2,000 ms |
| コード長 | 416 bytes |
| 記録 | |
| コンパイル時間 | 904 ms |
| コンパイル使用メモリ | 85,248 KB |
| 実行使用メモリ | 152,320 KB |
| 最終ジャッジ日時 | 2026-05-22 19:36:27 |
| 合計ジャッジ時間 | 4,091 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge3_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 25 |
ソースコード
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)
ygd.