結果

問題 No.2126 MEX Game
ユーザー lilictaka
提出日時 2023-01-03 21:28:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 812 bytes
コンパイル時間 458 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 126,408 KB
最終ジャッジ日時 2024-11-27 02:24:49
合計ジャッジ時間 3,668 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 2
権限があれば一括ダウンロードができます

ソースコード

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