結果

問題 No.2126 MEX Game
ユーザー ntudantuda
提出日時 2022-11-19 12:45:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 479 bytes
コンパイル時間 565 ms
コンパイル使用メモリ 11,824 KB
実行使用メモリ 21,592 KB
最終ジャッジ日時 2023-10-20 17:54:56
合計ジャッジ時間 2,407 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
10,072 KB
testcase_01 AC 28 ms
10,088 KB
testcase_02 AC 27 ms
10,072 KB
testcase_03 AC 27 ms
10,072 KB
testcase_04 AC 27 ms
10,696 KB
testcase_05 AC 23 ms
10,072 KB
testcase_06 AC 25 ms
10,072 KB
testcase_07 AC 24 ms
10,072 KB
testcase_08 AC 24 ms
10,072 KB
testcase_09 AC 25 ms
10,072 KB
testcase_10 AC 68 ms
21,592 KB
testcase_11 AC 69 ms
21,592 KB
testcase_12 AC 75 ms
21,592 KB
testcase_13 AC 70 ms
21,592 KB
testcase_14 AC 63 ms
21,576 KB
testcase_15 AC 65 ms
21,576 KB
testcase_16 AC 65 ms
21,452 KB
testcase_17 AC 64 ms
20,896 KB
testcase_18 AC 63 ms
21,204 KB
testcase_19 AC 53 ms
11,876 KB
testcase_20 AC 55 ms
11,876 KB
testcase_21 AC 63 ms
21,576 KB
testcase_22 AC 24 ms
10,072 KB
testcase_23 AC 25 ms
10,088 KB
testcase_24 AC 26 ms
10,072 KB
testcase_25 AC 24 ms
10,072 KB
testcase_26 AC 24 ms
10,072 KB
testcase_27 AC 25 ms
10,072 KB
testcase_28 AC 24 ms
10,072 KB
testcase_29 AC 24 ms
10,072 KB
権限があれば一括ダウンロードができます

ソースコード

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:
            i -= 1
            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