結果

問題 No.1285 ゴミ捨て
ユーザー vtr_codervtr_coder
提出日時 2020-11-13 21:41:20
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 20 ms / 2,000 ms
コード長 1,992 bytes
コンパイル時間 1,656 ms
コンパイル使用メモリ 173,124 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-19 07:15:21
合計ジャッジ時間 2,588 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 18 ms
4,376 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 8 ms
4,380 KB
testcase_10 AC 16 ms
4,380 KB
testcase_11 AC 15 ms
4,380 KB
testcase_12 AC 12 ms
4,376 KB
testcase_13 AC 11 ms
4,376 KB
testcase_14 AC 17 ms
4,376 KB
testcase_15 AC 13 ms
4,380 KB
testcase_16 AC 5 ms
4,376 KB
testcase_17 AC 5 ms
4,384 KB
testcase_18 AC 3 ms
4,376 KB
testcase_19 AC 8 ms
4,380 KB
testcase_20 AC 4 ms
4,376 KB
testcase_21 AC 5 ms
4,376 KB
testcase_22 AC 19 ms
4,376 KB
testcase_23 AC 20 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(int i=(l);i<int(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(int i=(l);i>=int(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

const int MOD = 1000000007;

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MAX_N = 100010;

signed main() {
    IOS;

    int N;
    cin >> N;
    V<> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    SORT(A);
    priority_queue<int, V<>, greater<int> > pq;
    REP(i, N) {
        if(i == 0) { pq.push(A[i]); continue; }
        int a = pq.top();
        pq.pop();
        if(a + 1 >= A[i]) {
            pq.push(a);
        }
        pq.push(A[i]);
    }
    print(pq.size());

    return 0;
}
0