結果
| 問題 |
No.2796 Small Matryoshka
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-28 21:36:16 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 191 ms / 2,000 ms |
| コード長 | 1,192 bytes |
| コンパイル時間 | 2,342 ms |
| コンパイル使用メモリ | 201,800 KB |
| 最終ジャッジ日時 | 2025-02-22 00:58:00 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
//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();
}