結果

問題 No.1285 ゴミ捨て
ユーザー nawawan
提出日時 2020-11-13 21:35:14
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 515 bytes
コンパイル時間 794 ms
コンパイル使用メモリ 91,832 KB
実行使用メモリ 13,440 KB
最終ジャッジ日時 2024-11-28 21:44:04
合計ジャッジ時間 2,197 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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