結果
問題 | No.2796 Small Matryoshka |
ユーザー | Nzt3 |
提出日時 | 2024-06-28 22:54:14 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 125 ms / 2,000 ms |
コード長 | 681 bytes |
コンパイル時間 | 2,015 ms |
コンパイル使用メモリ | 209,992 KB |
実行使用メモリ | 14,208 KB |
最終ジャッジ日時 | 2024-06-28 22:54:18 |
合計ジャッジ時間 | 3,915 ms |
ジャッジサーバーID (参考情報) |
judge4 / 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'; }