結果
| 問題 |
No.1438 Broken Drawers
|
| コンテスト | |
| ユーザー |
ygd.
|
| 提出日時 | 2021-03-26 21:29:34 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 210 ms / 2,000 ms |
| コード長 | 416 bytes |
| コンパイル時間 | 309 ms |
| コンパイル使用メモリ | 82,236 KB |
| 実行使用メモリ | 117,852 KB |
| 最終ジャッジ日時 | 2024-11-28 21:31:45 |
| 合計ジャッジ時間 | 5,118 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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.