結果

問題 No.2796 Small Matryoshka
ユーザー shinchanshinchan
提出日時 2024-06-28 21:43:56
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 825 bytes
コンパイル時間 2,855 ms
コンパイル使用メモリ 212,568 KB
実行使用メモリ 18,980 KB
最終ジャッジ日時 2024-06-28 21:44:02
合計ジャッジ時間 4,860 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 19 ms
5,560 KB
testcase_06 AC 116 ms
16,924 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 89 ms
13,880 KB
testcase_09 AC 161 ms
18,824 KB
testcase_10 AC 160 ms
18,720 KB
testcase_11 AC 161 ms
18,980 KB
testcase_12 AC 51 ms
10,384 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 47 ms
9,680 KB
testcase_15 AC 13 ms
5,376 KB
testcase_16 AC 22 ms
6,228 KB
testcase_17 AC 96 ms
12,624 KB
testcase_18 AC 111 ms
14,052 KB
testcase_19 AC 31 ms
6,672 KB
testcase_20 AC 43 ms
7,824 KB
testcase_21 AC 95 ms
12,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define all(v) (v).begin(),(v).end()
#define pb(a) push_back(a)
#define rep(i, n) for(int i=0;i<n;i++)
#define foa(e, v) for(auto& e : v)
using ll = long long;
const ll MOD7 = 1000000007, MOD998 = 998244353, INF = (1LL << 60);
#define dout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<ll> a(n), b(n);
    vector<pair<ll, ll>> v;
    rep(i, n) {
        cin >> a[i] >> b[i];
        v.push_back({a[i], b[i]});
    }
    sort(all(v));
    multiset<ll> ms;
    foa(e, v) ms.insert(e.first);
    ll ans = 0;
    for(auto [x, y] : v) {
        auto itr = ms.lower_bound(y);
        if(itr == ms.end()) ans ++;
        else ms.erase(itr);
    }
    cout << ans - 1<< endl;
    return 0;
}
0