結果

問題 No.2126 MEX Game
ユーザー lilictakalilictaka
提出日時 2023-01-03 21:17:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 870 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 81,664 KB
実行使用メモリ 126,336 KB
最終ジャッジ日時 2024-05-05 07:36:59
合計ジャッジ時間 3,364 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
52,992 KB
testcase_01 AC 50 ms
53,248 KB
testcase_02 AC 46 ms
52,864 KB
testcase_03 AC 46 ms
52,864 KB
testcase_04 AC 45 ms
53,120 KB
testcase_05 AC 46 ms
52,864 KB
testcase_06 AC 46 ms
52,864 KB
testcase_07 AC 46 ms
53,504 KB
testcase_08 AC 46 ms
53,760 KB
testcase_09 AC 45 ms
52,992 KB
testcase_10 AC 124 ms
107,136 KB
testcase_11 AC 123 ms
107,264 KB
testcase_12 AC 125 ms
107,264 KB
testcase_13 AC 124 ms
107,136 KB
testcase_14 AC 128 ms
99,584 KB
testcase_15 AC 129 ms
99,200 KB
testcase_16 AC 129 ms
99,840 KB
testcase_17 AC 85 ms
85,120 KB
testcase_18 AC 86 ms
85,120 KB
testcase_19 AC 75 ms
81,152 KB
testcase_20 AC 75 ms
81,024 KB
testcase_21 AC 146 ms
126,336 KB
testcase_22 AC 47 ms
53,504 KB
testcase_23 AC 46 ms
53,248 KB
testcase_24 AC 45 ms
53,120 KB
testcase_25 WA -
testcase_26 AC 47 ms
53,632 KB
testcase_27 AC 46 ms
53,248 KB
testcase_28 AC 46 ms
53,504 KB
testcase_29 AC 46 ms
53,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
N = int(input())
A = list(map(int,input().split()))
cnt = defaultdict(int)
for a in A:
    cnt[a] +=1
one = []
two = []
other = 0
for key in cnt.keys():
    if cnt[key] == 1:
        one.append(key)
    elif cnt[key] == 2:
        two.append(key)
    else:
        other +=1
setA = set(A)
for i in range(N+1):
    if i in setA:
        pass
    else:
        ans = i
        break
one.sort()
two.sort()
if len(one) >= 1:
    if other:
        if len(one) >= 2:
            ans = min(ans,one[1]) 
    else:
        if len(two) >= 1 and two[-1] > one[0]:
            if len(one) >= 2:
                co = max(two[-1],one[1])
            else:
                co = two[-1]
            ans = min(co,ans)
        if len(one) >=2:
            ans = min(ans,one[1])
        else:
            ans = min(ans,one[0])

else:
    pass
print(ans)
0