結果

問題 No.2126 MEX Game
ユーザー aaaaaaaaaa2230
提出日時 2022-11-18 22:48:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 544 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 100,352 KB
最終ジャッジ日時 2024-09-20 03:17:33
合計ジャッジ時間 2,822 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
n = int(input())
A = list(map(int,input().split()))
A.sort()
if A[0] != 0:
    print(0)
    exit()

C = Counter(A)

s = sorted(C.keys())

more = 0
done = 0
last = -1
for x in s:
    if last+1 != x:
        print(last+1)
        exit()
    last = x
    if C[x] == 2:
        continue
    if C[x] > 2:
        more = 1
        continue

    if x != max(s) or more:
        if done:
            print(x)
            exit()
        else:
            done = 1
    else:
        print(x)
        exit()


print(last+1)
0