結果
問題 | No.2796 Small Matryoshka |
ユーザー |
|
提出日時 | 2024-06-28 21:51:07 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 173 ms / 2,000 ms |
コード長 | 758 bytes |
コンパイル時間 | 2,700 ms |
コンパイル使用メモリ | 248,444 KB |
実行使用メモリ | 14,464 KB |
最終ジャッジ日時 | 2024-06-28 21:51:13 |
合計ジャッジ時間 | 5,087 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; using LL = long long; const int mxn = 2e5 + 10; int n; struct node { int R, r; bool operator < (const node &rhs) const { return R == rhs.R ? r > rhs.r : R > rhs.R; } } a[mxn]; multiset<node> s; int main() { ios::sync_with_stdio(false); cin >> n; for (int i = 1; i <= n; ++i) { cin >> a[i].r >> a[i].R; s.insert(a[i]); } int ans = -1; while (!s.empty()) { ++ans; node x = *begin(s); s.erase(begin(s)); for (auto it = s.lower_bound({ x.r, INT_MAX }); it != end(s);) { assert(x.r >= it -> R); // printf("x = (%d, %d), it = (%d, %d)\n", // x.R, x.r, it -> R, it -> r); x = *it; s.erase(it); it = s.lower_bound({ x.r, INT_MAX }); } } cout << ans << "\n"; return 0; }