結果

問題 No.2126 MEX Game
ユーザー ripityripity
提出日時 2022-11-18 23:16:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 852 bytes
コンパイル時間 3,713 ms
コンパイル使用メモリ 206,028 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-20 08:16:29
合計ジャッジ時間 3,788 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main() {
    int N;
    cin >> N;
    vector<int> A(N), cnt(100001);
    for( int i = 0; i < N; i++ ) {
        cin >> A[i];
        cnt[A[i]]++;
    }
    bool flag = true, ge_two = false;
    sort(A.begin(), A.end());
    for( int i = 0; i <= 100000; i++ ) {
        if( cnt[i] == 0 ) {
            cout << i << endl;
            break;
        }else if( cnt[i] == 1 ) {
            if( flag ) {
                if( A[N-1] == i ) {
                    if( !ge_two ) {
                        cout << 0 << endl;
                        break;
                    }
                }else {
                    cnt[i]++;
                    cnt[A[N-1]]--;
                }
            }else {
                cout << i << endl;
            }
        }else {
            ge_two = true;
        }
    }
}
0