結果

問題 No.1285 ゴミ捨て
ユーザー ぷらぷら
提出日時 2020-11-13 21:31:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 208 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 2,030 ms
コンパイル使用メモリ 177,308 KB
実行使用メモリ 22,784 KB
最終ジャッジ日時 2024-05-06 14:27:24
合計ジャッジ時間 4,545 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 2 ms
6,940 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 197 ms
22,016 KB
testcase_08 AC 6 ms
6,940 KB
testcase_09 AC 74 ms
11,392 KB
testcase_10 AC 161 ms
19,456 KB
testcase_11 AC 148 ms
18,304 KB
testcase_12 AC 104 ms
14,208 KB
testcase_13 AC 108 ms
14,208 KB
testcase_14 AC 188 ms
20,992 KB
testcase_15 AC 130 ms
15,872 KB
testcase_16 AC 29 ms
6,940 KB
testcase_17 AC 30 ms
7,040 KB
testcase_18 AC 29 ms
6,940 KB
testcase_19 AC 67 ms
10,548 KB
testcase_20 AC 26 ms
6,940 KB
testcase_21 AC 38 ms
7,936 KB
testcase_22 AC 206 ms
22,784 KB
testcase_23 AC 208 ms
22,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 3e18;
int mod = 1e9+7;
int dx[4] = {1, 0,-1, 0};
int dy[4] = {0, 1, 0,-1};
signed main() {
    int N;
    cin >> N;
    vector<int>A(N);
    map<int,int>Mp;
    int ans = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        Mp[A[i]]++;
        ans = max(ans,Mp[A[i]]+Mp[A[i]+1]);
        ans = max(ans,Mp[A[i]]+Mp[A[i]-1]);
    }
    cout << ans << endl;
}
0