結果
| 問題 |
No.2796 Small Matryoshka
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-28 22:44:00 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 134 ms / 2,000 ms |
| コード長 | 1,197 bytes |
| コンパイル時間 | 2,257 ms |
| コンパイル使用メモリ | 188,268 KB |
| 実行使用メモリ | 14,208 KB |
| 最終ジャッジ日時 | 2024-06-28 22:44:16 |
| 合計ジャッジ時間 | 4,258 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <deque>
#include <forward_list>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <optional>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
cin >> n;
vector<pair<int,int>> R(n);
for (auto &r : R) cin >> r.first >> r.second;
sort(R.begin(),R.end(),[](auto a, auto b){
if (a.second == b.second) return a.first < b.first;
return a.second < b.second;
});
multiset<int> S;
for (auto [l,r] : R){
auto it = S.upper_bound(l);
if (it != S.begin()){
S.erase(--it);
}
S.insert(r);
}
cout << S.size()-1 << endl;
return 0;
}