結果

問題 No.2126 MEX Game
コンテスト
ユーザー gr1msl3y
提出日時 2022-11-26 12:16:42
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 540 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 89 ms
コンパイル使用メモリ 64,908 KB
実行使用メモリ 70,024 KB
最終ジャッジ日時 2026-10-20 07:38:30
合計ジャッジ時間 3,792 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

N = int(input())
A = list(map(int, input().split()))
A.sort()
indl = 0
indr = N
res = 0
M = 10**5
ct1 = 0
for i in range(M):
    ct = 0
    while indl < indr and A[indl] == i:
        ct += 1
        indl += 1
    if ct == 0:
        print(i)
        exit()
    if ct == 1:
        ct1 += 1
        if ct1 == 2:
            print(i)
            exit()
        if res:
            res -= 1
        elif indl == indr:
            print(i)
            exit()
        else:
            indr -= 1
        indr -= 1
    else:
        res += ct-2
0