結果
問題 |
No.2126 MEX Game
|
ユーザー |
|
提出日時 | 2022-11-18 22:25:54 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,421 bytes |
コンパイル時間 | 1,813 ms |
コンパイル使用メモリ | 191,752 KB |
最終ジャッジ日時 | 2025-02-08 21:56:22 |
ジャッジサーバーID (参考情報) |
judge1 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 WA * 4 |
ソースコード
#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]==2){ at=j; break; } } if(at>i){ C[at]--; flag=false; }else{ cout<<i<<"\n"; return 0; } } }else{ cout<<i<<"\n"; return 0; } } } }