結果
| 問題 |
No.2796 Small Matryoshka
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-06-28 21:51:54 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,098 bytes |
| コンパイル時間 | 4,774 ms |
| コンパイル使用メモリ | 322,812 KB |
| 実行使用メモリ | 47,396 KB |
| 最終ジャッジ日時 | 2024-06-28 21:52:06 |
| 合計ジャッジ時間 | 9,955 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 11 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using mint = atcoder::static_modint<998244353>;
//using mint = atcoder::static_modint<1000000007>;
using namespace std;
using namespace atcoder;
using ld = long double;
using ll = long long;
#define mp(a,b) make_pair(a,b)
#define rep(i,s,n) for(int i=s; i<n; i++)
int op(int x,int y){return max(x,y);}
int e(){return 0;}
int main(){
int n;
cin >> n;
set<int> S;
vector<pair<int,int>> r(n);
rep(i,0,n){
cin >> r[i].first >> r[i].second;
S.insert(r[i].first);
S.insert(r[i].second);
}
map<int,int> f;
int k=0;
auto itr=S.begin();
while(itr!=S.end()){
f[*itr]=k;
k++;
itr++;
}
rep(i,0,n){
r[i].first=f[r[i].first];
r[i].second=f[r[i].second];
}
sort(r.begin(),r.end());
segtree<int,op,e> seg(3*n);
rep(i,0,n){
int a=r[i].first,b=r[i].second;
//cout << a << " " << b << "\n";
int score=seg.prod(0,a+1)+1;
seg.set(b,max(score,seg.get(b)));
}
int ans=n-seg.all_prod();
cout << ans;
}