結果

問題 No.2796 Small Matryoshka
ユーザー makichanmakichan
提出日時 2024-06-28 22:12:12
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 262 ms / 2,000 ms
コード長 755 bytes
コンパイル時間 5,806 ms
コンパイル使用メモリ 314,892 KB
実行使用メモリ 14,336 KB
最終ジャッジ日時 2024-06-28 22:12:21
合計ジャッジ時間 8,806 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,940 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 27 ms
6,940 KB
testcase_06 AC 164 ms
6,940 KB
testcase_07 AC 2 ms
6,940 KB
testcase_08 AC 127 ms
6,944 KB
testcase_09 AC 232 ms
14,336 KB
testcase_10 AC 229 ms
14,208 KB
testcase_11 AC 262 ms
14,336 KB
testcase_12 AC 61 ms
6,940 KB
testcase_13 AC 9 ms
6,944 KB
testcase_14 AC 53 ms
6,940 KB
testcase_15 AC 16 ms
6,944 KB
testcase_16 AC 27 ms
6,940 KB
testcase_17 AC 148 ms
6,940 KB
testcase_18 AC 169 ms
7,424 KB
testcase_19 AC 50 ms
6,940 KB
testcase_20 AC 70 ms
6,940 KB
testcase_21 AC 144 ms
7,040 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::static_modint<998244353>;
//using mint = atcoder::static_modint<1000000007>;
using namespace std;
using namespace atcoder;
using ld = long double;
using ll = long long;
#define mp(a,b) make_pair(a,b)
#define rep(i,s,n) for(int i=s; i<n; i++)

const int inf=2e9;
int main(){
    int n;
    cin >> n;
    vector<pair<int,int>> r(n);
    rep(i,0,n)cin >> r[i].first >> r[i].second;
    sort(r.begin(),r.end());
    multiset<int> S;
    rep(i,0,n){
        int a=r[i].first,b=r[i].second;
        auto itr=S.upper_bound(a);
        if(itr!=S.begin()){
            itr--;
            S.erase(itr);
            S.insert(b);
        }
        else S.insert(b);
    }
    cout << S.size()-1;
}
0