結果

問題 No.1285 ゴミ捨て
ユーザー kappybarkappybar
提出日時 2020-11-15 19:53:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 855 bytes
コンパイル時間 1,849 ms
コンパイル使用メモリ 170,716 KB
実行使用メモリ 8,580 KB
最終ジャッジ日時 2023-08-19 07:22:46
合計ジャッジ時間 3,662 ms
ジャッジサーバーID
(参考情報)
judge9 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,384 KB
testcase_04 AC 1 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,388 KB
testcase_07 AC 74 ms
8,368 KB
testcase_08 AC 4 ms
4,380 KB
testcase_09 AC 30 ms
5,412 KB
testcase_10 AC 64 ms
7,432 KB
testcase_11 AC 59 ms
7,164 KB
testcase_12 AC 42 ms
6,060 KB
testcase_13 AC 42 ms
6,156 KB
testcase_14 AC 70 ms
8,192 KB
testcase_15 AC 48 ms
6,388 KB
testcase_16 AC 13 ms
4,384 KB
testcase_17 AC 13 ms
4,384 KB
testcase_18 AC 12 ms
4,380 KB
testcase_19 AC 27 ms
5,284 KB
testcase_20 AC 11 ms
4,384 KB
testcase_21 AC 16 ms
4,428 KB
testcase_22 AC 78 ms
8,504 KB
testcase_23 AC 77 ms
8,580 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr ll INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    set<ll> st;
    rep(i,n) st.insert(a[i]);
    int cnt = 0;
    while(!st.empty()){
        auto it = st.begin();
        while(it != st.end()){
            auto itr = st.upper_bound((*it)+1);
            if(itr == st.end()){
                st.erase(it);
                break;
            }
            else{
                st.erase(it);
                it = itr;
            }
        }
        ++cnt;
    }
    cout << cnt << endl;

    return 0;
}
0