結果
問題 | No.2796 Small Matryoshka |
ユーザー |
👑 ![]() |
提出日時 | 2024-06-19 04:59:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 302 ms / 2,000 ms |
コード長 | 530 bytes |
コンパイル時間 | 2,310 ms |
コンパイル使用メモリ | 206,776 KB |
最終ジャッジ日時 | 2025-02-21 23:17:53 |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 |
ソースコード
#include<bits/stdc++.h> using namespace std; int main(){ int N; cin >> N; vector<pair<int, int>> p(N); for (int i = 0; i < N; i++) cin >> p[i].first >> p[i].second; sort(p.begin(), p.end(), [&](pair<int, int> l, pair<int,int> r){ return l.second > r.second; }); set<pair<int, int>> s; s.insert({1 << 30, -1}); int ans = N - 1; for (int i = 0; i < N;i++){ auto tmp = (*s.lower_bound({p[i].second, -1})); if (tmp.second != -1){ s.erase(tmp); ans--; } s.insert({p[i].first, i}); } cout << ans << "\n"; }