結果

問題 No.2126 MEX Game
ユーザー lilictakalilictaka
提出日時 2023-01-03 21:28:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 812 bytes
コンパイル時間 309 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 126,464 KB
最終ジャッジ日時 2024-05-05 07:37:22
合計ジャッジ時間 3,351 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,504 KB
testcase_01 AC 40 ms
53,632 KB
testcase_02 AC 43 ms
53,888 KB
testcase_03 AC 41 ms
53,760 KB
testcase_04 AC 39 ms
53,632 KB
testcase_05 AC 40 ms
54,016 KB
testcase_06 AC 45 ms
53,376 KB
testcase_07 AC 41 ms
54,016 KB
testcase_08 AC 41 ms
53,760 KB
testcase_09 AC 39 ms
53,760 KB
testcase_10 AC 109 ms
107,648 KB
testcase_11 AC 111 ms
107,264 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 113 ms
100,224 KB
testcase_15 AC 115 ms
100,096 KB
testcase_16 AC 116 ms
99,968 KB
testcase_17 AC 75 ms
84,864 KB
testcase_18 AC 77 ms
85,760 KB
testcase_19 AC 67 ms
81,408 KB
testcase_20 AC 74 ms
81,408 KB
testcase_21 AC 140 ms
126,464 KB
testcase_22 AC 47 ms
53,888 KB
testcase_23 AC 46 ms
53,376 KB
testcase_24 AC 46 ms
53,632 KB
testcase_25 AC 45 ms
53,632 KB
testcase_26 AC 45 ms
53,632 KB
testcase_27 AC 46 ms
53,632 KB
testcase_28 AC 41 ms
53,888 KB
testcase_29 AC 39 ms
53,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
cnt = defaultdict(int)
for a in A:
    cnt[a] +=1
one = []
two = []
other = 0
for key in cnt.keys():
    if cnt[key] == 1:
        one.append(key)
    elif cnt[key] == 2:
        two.append(key)
    else:
        other +=1
setA = set(A)
for i in range(N+1):
    if i in setA:
        pass
    else:
        ans = i
        break
one.sort()
two.sort()
if len(one) >= 1:
    if other:
        if len(one) >= 2:
            ans = min(ans,one[1]) 
    else:
        co = -1
        if len(one) >=2:
            co = one[1]
        if len(two) >= 1 and two[-1] > one[0]:
            co = max(co,two[-1])
        if co == -1:
            ans = min(ans,one[0])
        else:
            ans = min(ans,co)

else:
    pass
print(ans)
0