結果
| 問題 |
No.2126 MEX Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-18 22:28:13 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 11 ms / 2,000 ms |
| コード長 | 1,421 bytes |
| コンパイル時間 | 1,728 ms |
| コンパイル使用メモリ | 192,324 KB |
| 最終ジャッジ日時 | 2025-02-08 21:57:33 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 27 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}
int n,C[100010];;
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin>>n;
rep(i,n){
int a;
cin>>a;
C[a]++;
}
bool flag=true,flag2=false;
rep(i,100010)if(C[i]>2)flag2=true;
rep(i,100010){
if(C[i]==0){
cout<<i<<"\n";
return 0;
}else if(C[i]==1){
if(flag){
if(flag2){
flag=false;
}else{
int at=-1;
rrep(j,100010){
if(C[j]>=1){
at=j;
break;
}
}
if(at>i){
C[at]--;
flag=false;
}else{
cout<<i<<"\n";
return 0;
}
}
}else{
cout<<i<<"\n";
return 0;
}
}
}
}