結果

問題 No.2126 MEX Game
ユーザー aoblue2547aoblue2547
提出日時 2024-01-18 21:59:05
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 2,448 bytes
コンパイル時間 4,955 ms
コンパイル使用メモリ 308,460 KB
実行使用メモリ 7,200 KB
最終ジャッジ日時 2024-01-18 21:59:12
合計ジャッジ時間 7,193 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
7,200 KB
testcase_01 AC 4 ms
7,200 KB
testcase_02 AC 3 ms
7,200 KB
testcase_03 AC 3 ms
7,200 KB
testcase_04 AC 4 ms
7,200 KB
testcase_05 AC 4 ms
7,200 KB
testcase_06 AC 4 ms
7,200 KB
testcase_07 AC 4 ms
7,200 KB
testcase_08 AC 4 ms
7,200 KB
testcase_09 AC 4 ms
7,200 KB
testcase_10 AC 31 ms
7,200 KB
testcase_11 AC 31 ms
7,200 KB
testcase_12 AC 31 ms
7,200 KB
testcase_13 AC 31 ms
7,200 KB
testcase_14 AC 53 ms
7,200 KB
testcase_15 AC 31 ms
7,200 KB
testcase_16 AC 30 ms
7,200 KB
testcase_17 AC 26 ms
7,200 KB
testcase_18 AC 27 ms
7,200 KB
testcase_19 AC 18 ms
7,200 KB
testcase_20 AC 19 ms
7,200 KB
testcase_21 AC 31 ms
7,200 KB
testcase_22 AC 4 ms
7,200 KB
testcase_23 AC 4 ms
7,200 KB
testcase_24 AC 4 ms
7,200 KB
testcase_25 AC 5 ms
7,200 KB
testcase_26 AC 4 ms
7,200 KB
testcase_27 AC 4 ms
7,200 KB
testcase_28 AC 3 ms
7,200 KB
testcase_29 AC 3 ms
7,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//テンプレート
//Visual Studio用
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
template<class T> bool chmin(T& a, T b) { return a > b ? a = b, true : false; }
template<class T> bool chmax(T& a, T b) { return a < b ? a = b, true : false; }
template<class T>istream& operator>>(istream& is, vector<T>& v) { for (auto& e : v)is >> e; return is; }
template<class T>ostream& operator<<(ostream& os, vector<T>& v) { for (auto& e : v)os << e << " "; return os; }
using ll = long long;
using ull = unsigned long long;
using uint = unsigned int;
template<class T = ll> struct Edge {
	int to;
	T weight;
	Edge(int t, T w) :to(t), weight(w) {}
	bool operator==(Edge e) {
		return this->to == e.to and this->weight == e.weight;
	}
	bool operator<(Edge e) {
		if (this->to < e.to) {
			return this->weight <= e.weight;
		}
		else return false;
	}
};
template<class T = ll> class Graph {
	using graph_ = vector<vector<Edge<T>>>;
	graph_ g;
public:
	Graph(int n) :g(n) {}
	graph_::iterator begin() { return g.begin(); }
	graph_::const_iterator begin() const { return g.begin(); }
	graph_::iterator end() { return g.end(); }
	graph_::const_iterator end() const { return g.end(); }
	vector<Edge<T>>& operator [](int v) {
		return g[v];
	}
	const graph_& data() { return g; }
	void add(int u, int v, T w = 1) {
		g[u].emplace_back(Edge<T>{ v, w });
	}
	void wadd(int u, int v, T w = 1) {
		add(u, v, w);
		add(v, u, w);
	}
};

//Atcoder Library
/**/
#include <atcoder/all>
using namespace atcoder;
//using mint = modint998244353;
using mint = modint1000000007;
//using mint = dynamic_modint<0>;
//using mint = modint;
//mint::set_mod();
istream& operator>>(istream& is, mint& x) { ll r; cin >> r; x = r; return is; }
ostream& operator<<(ostream& os, mint& x) { cout << x.val(); return os; }
/**/
#define SHOW(n) cerr << #n << " = " << n << endl;

/*
ここまでテンプレート
*/



int main() {
	
	int n;
	cin >> n;
	vector<int> a(1000001);
	for (int i = 0; i < n; ++i) {
		int x;
		cin >> x;
		a[x]++;
	}

	int idx = -1;
	for (int i = 0; i <= 100000; ++i) {
		if (a[i] >= 3) {
			idx = i;
			break;
		}
	}
	if (idx == -1) {
		for (int i = 100000; i >= 0; --i) {
			if (a[i] > 0) {
				idx = i;
				break;
			}
		}
	}
	--a[idx];
	for (int i = 0; i <= 100000; ++i) {
		if (a[i] <= 1) {
			a[i]++;
			break;
		}
	}

	for (int i = 0; i <= 100000; ++i) {
		if (a[i] <= 1) {
			cout << i << endl;
			break;
		}
	}

	return 0;
}
0