結果
問題 | No.2796 Small Matryoshka |
ユーザー |
![]() |
提出日時 | 2024-06-29 12:47:29 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 158 ms / 2,000 ms |
コード長 | 732 bytes |
コンパイル時間 | 2,153 ms |
コンパイル使用メモリ | 204,680 KB |
最終ジャッジ日時 | 2025-02-22 01:34:43 |
ジャッジサーバーID (参考情報) |
judge4 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include <bits/stdc++.h> using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int n; cin >> n; vector<pair<int, int>> rR(n); for (int i = 0; i < n; i++) { cin >> rR[i].first >> rR[i].second; } sort(rR.begin(), rR.end()); multiset<int> st; for (auto [r, R] : rR) { if (st.empty()) { st.insert(R); } else { auto it = st.lower_bound(r + 1); if (it == st.begin()) { st.insert(R); } else { it--; st.erase(it); st.insert(R); } } } cout << st.size() - 1 << endl; }