結果

問題 No.2126 MEX Game
ユーザー HIcoderHIcoder
提出日時 2023-07-11 11:17:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,498 bytes
コンパイル時間 1,132 ms
コンパイル使用メモリ 101,904 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-11 02:42:06
合計ジャッジ時間 4,428 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,368 KB
testcase_03 AC 2 ms
4,368 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 2 ms
4,372 KB
testcase_07 AC 2 ms
4,368 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 3 ms
4,372 KB
testcase_10 AC 28 ms
4,372 KB
testcase_11 AC 27 ms
4,368 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 28 ms
4,372 KB
testcase_15 AC 28 ms
4,368 KB
testcase_16 AC 27 ms
4,368 KB
testcase_17 AC 22 ms
4,368 KB
testcase_18 AC 24 ms
4,376 KB
testcase_19 AC 15 ms
4,368 KB
testcase_20 AC 16 ms
4,372 KB
testcase_21 WA -
testcase_22 AC 2 ms
4,372 KB
testcase_23 AC 1 ms
4,368 KB
testcase_24 AC 2 ms
4,368 KB
testcase_25 AC 2 ms
4,368 KB
testcase_26 AC 2 ms
4,372 KB
testcase_27 AC 2 ms
4,368 KB
testcase_28 AC 1 ms
4,368 KB
testcase_29 AC 2 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<set>
#include<algorithm>
#include<vector>
#include<string>
#include<set>
#include<map>
#include<numeric>
#include<queue>
#include<cmath>
using namespace std;
typedef long long ll;
const ll INF=1LL<<60;
typedef pair<int,int> P;
typedef pair<int,P> PP;
const ll MOD=998244353;
const double PI=acos(-1);


int main(){
    int N;
    cin>>N;

    const int MAXN=100000;
    vector<int> cnt(100000+10,0);
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
        cnt[A[i]]++;
    }

    int last=-1;
    for(int i=0;i<=MAXN;i++){
        if(cnt[i]==0){
            last=i;
            break;
        }
    }

    bool flag=false;
    for(int i=0;i<last;i++){
        if(cnt[i]<2){
            flag=true;
        }
    }

    if(!flag){
        cout<<last<<endl;
        return 0;
    }
    

    bool flag2=true;
    int cnt1=0;
    for(int i=0;i<last;i++){
        if(cnt[i]==1){
            cnt1++;
        }
        else if(cnt[i]==0){
            flag2=false;
        }
    }

    if(cnt1>1)flag2=false;

    if(flag2){
        bool flag3=false;
        for(int i=0;i<last;i++){
            if(cnt[i]>2)flag3=true;
        }

        for(int i=last;i<=MAXN;i++){
            if(cnt[i]>=1)flag3=true;
        }

        if(flag3){
            cout<<last<<endl;
        }else{
            cout<<last-1<<endl;
        }
        // cout<<"te"<<endl;

        // cout<<last<<endl;
    }else{
        //cout<<"ter"<<endl;
        cout<<last-1<<endl;
    }



}
0