結果

問題 No.2126 MEX Game
コンテスト
ユーザー 👑 rin204
提出日時 2022-11-18 21:34:02
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 56 ms / 2,000 ms
+ 510µs
コード長 478 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 89 ms
コンパイル使用メモリ 64,640 KB
実行使用メモリ 70,592 KB
最終ジャッジ日時 2026-10-19 06:46:57
合計ジャッジ時間 3,302 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 28
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n = int(input())
A = list(map(int, input().split()))
cnt = [0] * (10 ** 5 + 1)
for a in A:
    cnt[a] += 1

tot = 0
flg = False
for i in range(10 ** 5):
    tot += min(cnt[i], 2)
    if cnt[i] == 0:
        print(i)
        break
    elif cnt[i] == 1:
        if flg:
            print(i)
            break
        if tot == n:
            print(i)
            break
        else:
            flg = True
    elif cnt[i] == 2 and flg and tot == n:
        print(i)
        break
0