結果

問題 No.2126 MEX Game
ユーザー Nzt3Nzt3
提出日時 2022-11-18 22:18:46
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 509 bytes
コンパイル時間 2,039 ms
コンパイル使用メモリ 197,540 KB
最終ジャッジ日時 2025-02-08 21:51:50
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 24 WA * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin>>N;
  vector<int>A(N);
  for(int &i:A)cin>>i;
  sort(A.begin(),A.end());
  A.push_back(1e9);
  for(int i=0,f=0,t=0;i<=N;i++){
    if(A[i]!=t){
      cout<<t<<'\n';
      return 0;
    }
    if(A[i+1]==t){
      while(i<N&&A[i]==t)++i;
      --i;
      t+=1;
    }else if(f==0&&i<N-1){
      f=1;
      A[N-1]=1e9;
      t+=1;
    }else{
      cout<<t<<'\n';
      return 0;
    }
  }
}
0