結果

問題 No.1285 ゴミ捨て
ユーザー ぷらぷら
提出日時 2020-11-13 21:31:28
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 1,561 ms
コンパイル使用メモリ 175,004 KB
実行使用メモリ 22,628 KB
最終ジャッジ日時 2023-08-19 07:13:51
合計ジャッジ時間 4,022 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 150 ms
21,828 KB
testcase_08 AC 5 ms
4,376 KB
testcase_09 AC 56 ms
11,300 KB
testcase_10 AC 127 ms
19,460 KB
testcase_11 AC 116 ms
18,220 KB
testcase_12 AC 81 ms
14,264 KB
testcase_13 AC 83 ms
13,856 KB
testcase_14 AC 143 ms
20,832 KB
testcase_15 AC 93 ms
15,656 KB
testcase_16 AC 24 ms
6,760 KB
testcase_17 AC 25 ms
6,804 KB
testcase_18 AC 21 ms
6,476 KB
testcase_19 AC 50 ms
10,560 KB
testcase_20 AC 21 ms
6,428 KB
testcase_21 AC 30 ms
7,696 KB
testcase_22 AC 165 ms
22,576 KB
testcase_23 AC 167 ms
22,628 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