結果
問題 | No.2126 MEX Game |
ユーザー |
|
提出日時 | 2022-12-11 21:14:10 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 33 ms / 2,000 ms |
コード長 | 746 bytes |
コンパイル時間 | 681 ms |
コンパイル使用メモリ | 66,048 KB |
最終ジャッジ日時 | 2025-02-09 09:46:20 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
#include <iostream>using namespace std;int main(){int n;cin >> n;int d[100005]{0};for (int i = 0; i < n; i++){int a;cin >> a;d[a]++;}int s = 0;bool more2 = false;bool one = false;for (int a = 0; a <= n + 1; a++){s += d[a];if (d[a] == 0 || (d[a] == 1 && one)){if (s == n && d[a] == 0 && one && !more2){cout << a - 1 << endl;}else{cout << a << endl;}break;}if (d[a] == 1){one = true;}if (d[a] > 2){more2 = true;}}}