結果

問題 No.2126 MEX Game
ユーザー shobonvip
提出日時 2022-11-18 22:00:23
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 465 bytes
コンパイル時間 172 ms
コンパイル使用メモリ 82,500 KB
実行使用メモリ 81,664 KB
最終ジャッジ日時 2024-09-20 02:22:10
合計ジャッジ時間 2,490 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a = list(map(int,input().split()))

# 0, 0, 1, 2, 2, 3, 3
# -> 0, 0, 1, 1, 2, 2, 3
# の感じで1回だけ2にして安定させられる
# あとはまねっこ

mex = [0] * 100002
for i in range(n):
	mex[a[i]] += 1

mode = 1
mx = max(a)

for i in range(100002):
	if mex[i] == 1:
		if mode == 1:
			if mx == i:
				print(i)
				exit()
			mex[mx] -= 1
			mex[i] += 1
			mode = 0
		else:
			print(i)
			exit()
	if mex[i] == 0:
		print(i)
		exit()
	
0