結果

問題 No.1285 ゴミ捨て
ユーザー YamaKasaYamaKasa
提出日時 2020-11-14 15:29:31
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 110 ms / 2,000 ms
コード長 694 bytes
コンパイル時間 1,611 ms
コンパイル使用メモリ 172,816 KB
実行使用メモリ 8,476 KB
最終ジャッジ日時 2023-08-19 07:21:22
合計ジャッジ時間 3,691 ms
ジャッジサーバーID
(参考情報)
judge13 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 101 ms
8,252 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 39 ms
5,644 KB
testcase_10 AC 86 ms
7,712 KB
testcase_11 AC 78 ms
7,280 KB
testcase_12 AC 55 ms
6,268 KB
testcase_13 AC 53 ms
6,184 KB
testcase_14 AC 94 ms
7,956 KB
testcase_15 AC 66 ms
6,644 KB
testcase_16 AC 16 ms
4,592 KB
testcase_17 AC 17 ms
4,376 KB
testcase_18 AC 16 ms
4,380 KB
testcase_19 AC 35 ms
5,252 KB
testcase_20 AC 14 ms
4,376 KB
testcase_21 AC 21 ms
4,624 KB
testcase_22 AC 110 ms
8,420 KB
testcase_23 AC 110 ms
8,476 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