結果
| 問題 |
No.2126 MEX Game
|
| コンテスト | |
| ユーザー |
lilictaka
|
| 提出日時 | 2023-01-03 21:17:22 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 870 bytes |
| コンパイル時間 | 286 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 126,336 KB |
| 最終ジャッジ日時 | 2024-11-27 02:24:26 |
| 合計ジャッジ時間 | 3,264 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 26 WA * 1 |
ソースコード
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)
lilictaka