結果
問題 |
No.2126 MEX Game
|
ユーザー |
![]() |
提出日時 | 2025-04-15 22:23:30 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 721 bytes |
コンパイル時間 | 228 ms |
コンパイル使用メモリ | 81,828 KB |
実行使用メモリ | 99,664 KB |
最終ジャッジ日時 | 2025-04-15 22:25:45 |
合計ジャッジ時間 | 2,882 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 13 |
ソースコード
import sys from collections import defaultdict def main(): n = int(sys.stdin.readline()) a = list(map(int, sys.stdin.readline().split())) freq = defaultdict(int) for num in a: freq[num] += 1 # Compute initial mex mex = 0 while mex in freq: mex += 1 # Find the smallest x where count[x] == 1 and n > 1 candidate = None x = 0 while True: if x in freq and freq[x] == 1 and n > 1: candidate = x break if x > mex: # No need to check beyond the initial mex break x += 1 if candidate is not None: print(min(mex, candidate)) else: print(mex) if __name__ == "__main__": main()