結果

問題 No.2126 MEX Game
ユーザー HIcoderHIcoder
提出日時 2023-07-11 12:07:58
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 1,051 bytes
コンパイル時間 1,167 ms
コンパイル使用メモリ 102,584 KB
実行使用メモリ 4,376 KB
最終ジャッジ日時 2023-10-11 03:26:08
合計ジャッジ時間 2,835 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 2 ms
4,372 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 1 ms
4,372 KB
testcase_08 AC 2 ms
4,368 KB
testcase_09 AC 2 ms
4,372 KB
testcase_10 AC 27 ms
4,372 KB
testcase_11 AC 27 ms
4,368 KB
testcase_12 AC 27 ms
4,372 KB
testcase_13 AC 27 ms
4,368 KB
testcase_14 AC 28 ms
4,372 KB
testcase_15 AC 28 ms
4,372 KB
testcase_16 AC 28 ms
4,372 KB
testcase_17 AC 22 ms
4,372 KB
testcase_18 AC 24 ms
4,376 KB
testcase_19 AC 16 ms
4,372 KB
testcase_20 AC 16 ms
4,372 KB
testcase_21 AC 28 ms
4,368 KB
testcase_22 AC 2 ms
4,372 KB
testcase_23 AC 2 ms
4,372 KB
testcase_24 AC 2 ms
4,368 KB
testcase_25 AC 3 ms
4,368 KB
testcase_26 AC 2 ms
4,376 KB
testcase_27 AC 2 ms
4,372 KB
testcase_28 AC 2 ms
4,372 KB
testcase_29 AC 2 ms
4,372 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+1;
    vector<int> cnt(100000+10,0);
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    for(int i=0;i<N;i++){
        cnt[A[i]]++;
    }

    int ma=0;
    for(int i=0;i<N;i++){
        ma=max(ma,A[i]);
    }

    int maa=ma;
    for(int i=0;i<=MAXN;i++){
        if(cnt[i]>2){
            ma=i;
            break;
        }
    }

    for(int i=0;i<=maa;i++){
        if(cnt[i]<=1){
            cnt[i]++;//iの出現回数を1個以上にする必要がある
            cnt[ma]--;
            break;
        }
    }

    int ans=0;
    while(cnt[ans]>1)ans++;
    if(ans==100000 && cnt[ans]==1)ans++;

    cout<<ans<<endl;




}
0