結果

問題 No.2126 MEX Game
ユーザー ntuda
提出日時 2022-11-19 12:41:39
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 460 bytes
コンパイル時間 119 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 20,744 KB
最終ジャッジ日時 2024-09-20 13:30:34
合計ジャッジ時間 2,927 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
A = list(map(int, input().split()))
maxa = max(A)
X = [0] * (maxa + 1)
for a in A:
    X[a] += 1
cnt = 0
for i in range(maxa + 1):
    if X[i] == 0:
        i -= 1
        break
    elif X[i] == 1:
        if cnt == 0:
            cnt += 1
        else:
            break

if cnt == 0:
    print(i + 1)
else:
    if sum(X[:i + 1]) >= 2 * (i + 1):
        print(i + 1)
    elif N >= 2 * (i + 1):
        print(i + 1)
    else:
        print(i)
0