結果

問題 No.1285 ゴミ捨て
ユーザー YamaKasaYamaKasa
提出日時 2020-11-14 15:29:31
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 1,835 ms
コンパイル使用メモリ 176,308 KB
実行使用メモリ 8,576 KB
最終ジャッジ日時 2024-05-06 14:36:05
合計ジャッジ時間 3,834 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 3 ms
6,944 KB
testcase_07 AC 110 ms
8,192 KB
testcase_08 AC 5 ms
6,940 KB
testcase_09 AC 44 ms
6,940 KB
testcase_10 AC 98 ms
7,680 KB
testcase_11 AC 87 ms
7,296 KB
testcase_12 AC 61 ms
6,940 KB
testcase_13 AC 58 ms
6,944 KB
testcase_14 AC 116 ms
8,064 KB
testcase_15 AC 71 ms
6,944 KB
testcase_16 AC 18 ms
6,940 KB
testcase_17 AC 18 ms
6,944 KB
testcase_18 AC 16 ms
6,940 KB
testcase_19 AC 39 ms
6,944 KB
testcase_20 AC 15 ms
6,944 KB
testcase_21 AC 22 ms
6,940 KB
testcase_22 AC 123 ms
8,576 KB
testcase_23 AC 125 ms
8,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

int main() {
    int N;
    cin >> N;
    int A[N];
    map<int, int> m;
    int max_v = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        m[A[i]]++;
        chmax(max_v, m[A[i]]);
    }
    sort(A, A + N);
    bool flag = false;
    for (int i = 1; i < N; i++) {
        if (A[i - 1] + 1 == A[i]) {
            flag = true;
            break;
        }
    }
    if (flag) {
        cout << max(max_v, 2) << "\n";
    } else {
        cout << max_v << "\n";
    }
    return 0;
}
0