結果

問題 No.1285 ゴミ捨て
ユーザー nawawannawawan
提出日時 2020-11-13 21:35:14
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 1,135 ms
コンパイル使用メモリ 89,880 KB
実行使用メモリ 13,560 KB
最終ジャッジ日時 2023-08-19 07:14:31
合計ジャッジ時間 2,756 ms
ジャッジサーバーID
(参考情報)
judge14 / judge10
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 73 ms
12,880 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 29 ms
7,484 KB
testcase_10 AC 58 ms
11,424 KB
testcase_11 AC 56 ms
10,760 KB
testcase_12 AC 39 ms
9,080 KB
testcase_13 AC 39 ms
8,912 KB
testcase_14 AC 67 ms
12,224 KB
testcase_15 AC 46 ms
9,708 KB
testcase_16 AC 12 ms
5,100 KB
testcase_17 AC 12 ms
5,244 KB
testcase_18 AC 11 ms
4,952 KB
testcase_19 AC 27 ms
7,080 KB
testcase_20 AC 10 ms
4,988 KB
testcase_21 AC 14 ms
5,604 KB
testcase_22 AC 74 ms
13,016 KB
testcase_23 AC 75 ms
13,560 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    map<int, int> m;
    for(int i = 0; i < N; i++) m[A[i]]++;
    int ans = 0;
    for(int i = 0; i < N; i++){
        ans = max(ans, m[A[i]] + m[A[i] - 1]);
    }
    cout << ans << endl;
}
0