結果
| 問題 |
No.2796 Small Matryoshka
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-28 22:54:14 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 140 ms / 2,000 ms |
| コード長 | 681 bytes |
| コンパイル時間 | 2,019 ms |
| コンパイル使用メモリ | 204,508 KB |
| 最終ジャッジ日時 | 2025-02-22 01:18:46 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 19 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/fenwicktree>
using namespace std;
using ll=long long;
constexpr int MOD=998244353;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define replr(i,l,r) for(int i=(l);i<(int)(r);i++)
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin>>N;
vector A(N,array<int,2>());
for(auto &i:A)cin>>i[0]>>i[1];
sort(A.begin(),A.end(),[](array<int,2>& a,array<int,2>& b){
return a[1]<b[1];
});
multiset<int,greater<int>>ans;
ans.insert(0);
for(int i=0;i<N;i++){
auto it=ans.lower_bound(A[i][0]);
if(it!=ans.end()){
ans.erase(it);
}
ans.insert(A[i][1]);
}
cout<<(int)ans.size()-1<<'\n';
}