結果

問題 No.1285 ゴミ捨て
ユーザー H ShibusawaH Shibusawa
提出日時 2020-11-15 15:52:57
言語 C++17(clang)
(17.0.6 + boost 1.83.0)
結果
AC  
実行時間 49 ms / 2,000 ms
コード長 1,551 bytes
コンパイル時間 3,963 ms
コンパイル使用メモリ 136,304 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 07:22:03
合計ジャッジ時間 3,967 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 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,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 47 ms
4,376 KB
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 22 ms
4,380 KB
testcase_10 AC 43 ms
4,380 KB
testcase_11 AC 38 ms
4,376 KB
testcase_12 AC 29 ms
4,384 KB
testcase_13 AC 29 ms
4,376 KB
testcase_14 AC 45 ms
4,380 KB
testcase_15 AC 32 ms
4,376 KB
testcase_16 AC 10 ms
4,380 KB
testcase_17 AC 10 ms
4,380 KB
testcase_18 AC 9 ms
4,380 KB
testcase_19 AC 20 ms
4,380 KB
testcase_20 AC 9 ms
4,376 KB
testcase_21 AC 13 ms
4,380 KB
testcase_22 AC 49 ms
4,380 KB
testcase_23 AC 49 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define rep1(i,n) for(int i=1; i<(int)n; i++)
#define repa(i,a,n) for(int i=(a); i<(int)(n); i++)
#define all(vec) vec.begin(),vec.end()
#define COUT(x) cout<<(x)<<endl
#define YES(x) cout<<(x?"YES":"NO")<<endl
#define Yes(x) cout<<(x?"Yes":"No")<<endl
#define F first
#define S second
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vpii = vector<pii>;
const int dx[4] = {1, 0,-1, 0};
const int dy[4] = {0, 1, 0,-1};
int gcd(int a, int b){if(a%b == 0){return(b);}else{return(gcd(b, a%b));}}
int lcm(int a, int b){return a/gcd(a, b)*b;}
template <typename T> bool chmax(T &a,const T& b){if(a<b){a=b;return true;}return false;}
template <typename T> bool chmin(T &a,const T& b){if(a>b){a=b;return true;}return false;}
//cout << fixed << setprecision(15);
int N, M, K, H, W, X, Y;
string S,T;
const int INF = 1e18;
const int mod = 1e9+7;

vvi gr;
vector<bool> seen;
void dfs(int a){
    seen[a] = true;
    for(int i : gr[a]){
        if(seen[i]==false) dfs(i);
    }
    return;
}


signed main(){
    cin >> N;
    vi A(N);
    rep(i,N) cin >> A[i];
    sort(all(A));
    int ans = 1;
    vi B;
    while(A.size()>0){
        int cur = A[0];
        rep1(i,A.size()){
            if(A[i] <= cur + 1) B.push_back(A[i]);
            else cur = A[i];
        }
        if(B.size() == 0) break;
        A = B;
        B.clear();
        ans++;
    }
    COUT(ans);
    return 0;
}
0