結果

問題 No.2796 Small Matryoshka
ユーザー IntellegentIntellegent
提出日時 2024-06-28 21:36:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 140 ms / 2,000 ms
コード長 1,192 bytes
コンパイル時間 1,987 ms
コンパイル使用メモリ 210,216 KB
実行使用メモリ 14,336 KB
最終ジャッジ日時 2024-06-28 21:36:25
合計ジャッジ時間 4,205 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 1 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 17 ms
6,940 KB
testcase_06 AC 119 ms
12,800 KB
testcase_07 AC 2 ms
6,944 KB
testcase_08 AC 94 ms
10,752 KB
testcase_09 AC 137 ms
14,208 KB
testcase_10 AC 140 ms
14,336 KB
testcase_11 AC 139 ms
14,208 KB
testcase_12 AC 60 ms
8,320 KB
testcase_13 AC 8 ms
6,940 KB
testcase_14 AC 49 ms
7,680 KB
testcase_15 AC 13 ms
6,944 KB
testcase_16 AC 22 ms
6,944 KB
testcase_17 AC 97 ms
9,984 KB
testcase_18 AC 109 ms
10,752 KB
testcase_19 AC 29 ms
6,940 KB
testcase_20 AC 42 ms
6,940 KB
testcase_21 AC 91 ms
9,984 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//a

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define debug(x) cout << #x << " = " << x << "\n";
#define vdebug(a) cout << #a << " = "; for(auto x: a) cout << x << " "; cout << "\n";
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int uid(int a, int b) { return uniform_int_distribution<int>(a, b)(rng); }
ll uld(ll a, ll b) { return uniform_int_distribution<ll>(a, b)(rng); }

void solve(){
    int n;
    cin >> n;
    
    vector<array<int, 2>> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i][1] >> a[i][0];
        a[i][0] = -a[i][0];
        a[i][1] = -a[i][1];
    }
    
    multiset<array<int, 2>> s;
    for (array<int, 2> x : a) s.insert(x);
    
    int ans = 0;
    while (s.size()){
        array<int, 2> cur = *s.begin();
        s.erase(s.find(cur));
        
        auto low = s.lower_bound({cur[1], -INT_MAX});
        while (low != s.end()){
            cur = *low;
            s.erase(s.find(cur));
            low = s.lower_bound({cur[1], -INT_MAX});
        }
        
        ans++;
    }
    
    cout << ans - 1;
}

int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	cout.tie(0);
    
    solve();
}
0