結果

問題 No.1438 Broken Drawers
ユーザー ygd.ygd.
提出日時 2021-03-26 21:29:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 253 ms / 2,000 ms
コード長 416 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 87,284 KB
実行使用メモリ 146,180 KB
最終ジャッジ日時 2023-08-19 07:06:18
合計ジャッジ時間 7,051 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,580 KB
testcase_01 AC 95 ms
71,748 KB
testcase_02 AC 96 ms
71,636 KB
testcase_03 AC 97 ms
71,948 KB
testcase_04 AC 94 ms
71,856 KB
testcase_05 AC 95 ms
71,764 KB
testcase_06 AC 180 ms
144,516 KB
testcase_07 AC 179 ms
144,596 KB
testcase_08 AC 93 ms
71,704 KB
testcase_09 AC 95 ms
71,704 KB
testcase_10 AC 95 ms
71,688 KB
testcase_11 AC 109 ms
78,268 KB
testcase_12 AC 153 ms
101,668 KB
testcase_13 AC 186 ms
117,624 KB
testcase_14 AC 137 ms
94,016 KB
testcase_15 AC 240 ms
139,048 KB
testcase_16 AC 232 ms
139,084 KB
testcase_17 AC 240 ms
146,016 KB
testcase_18 AC 241 ms
145,828 KB
testcase_19 AC 240 ms
146,116 KB
testcase_20 AC 244 ms
145,868 KB
testcase_21 AC 251 ms
145,796 KB
testcase_22 AC 244 ms
146,112 KB
testcase_23 AC 250 ms
146,180 KB
testcase_24 AC 243 ms
146,060 KB
testcase_25 AC 253 ms
145,996 KB
testcase_26 AC 246 ms
146,076 KB
testcase_27 AC 242 ms
146,144 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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