結果

問題 No.1285 ゴミ捨て
ユーザー lam6er
提出日時 2025-03-20 18:59:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 629 bytes
コンパイル時間 2,844 ms
コンパイル使用メモリ 200,624 KB
実行使用メモリ 7,328 KB
最終ジャッジ日時 2025-03-20 19:00:08
合計ジャッジ時間 5,118 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 12 WA * 10
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int N;
    cin >> N;
    vector<int> A(N);
    for (int &a : A) {
        cin >> a;
    }
    sort(A.begin(), A.end());

    multiset<int> s;

    for (int y : A) {
        auto it = s.lower_bound(y);
        if (it == s.begin()) {
            s.insert(y);
        } else {
            --it;
            if (*it <= y - 2) {
                s.erase(it);
                s.insert(y);
            } else {
                s.insert(y);
            }
        }
    }

    cout << s.size() << endl;

    return 0;
}
0