結果

問題 No.2126 MEX Game
ユーザー 👑 CleyL
提出日時 2022-12-24 18:40:08
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 580 bytes
コンパイル時間 445 ms
コンパイル使用メモリ 71,172 KB
最終ジャッジ日時 2025-02-09 20:13:28
ジャッジサーバーID
(参考情報)
judge5 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n;cin>>n;
    vector<int> A(110000);
    for(int i = 0; n > i; i++){
        int x;cin>>x;
        A[x]++;
    }
    bool am = false;
    bool lck = false;
    int i = 0;
    int sm = 0;
    while(true){
        if(A[i] > 2)am = true;
        if(A[i] == 1 && (i+1)*2 <= n && !lck){
            lck = true;
        }else if(A[i] < 2){
            if(!am && lck && sm == n)cout << i-1 << endl;
            else cout << i << endl;
            return 0;
        }
        sm += A[i];
        i++;
    }
}
0