# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1273736 | nthvn | Exhibition (JOI19_ho_t2) | C++20 | 1 ms | 576 KiB |
#include "bits/stdc++.h"
using namespace std;
#define LOG(n) (63 - __builtin_clzll((n)))
#define fi first
#define se second
#define pii pair<int,int>
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pb push_back
#define ll long long
const int inf = 1e9+7;
const int N = 1e5+5;
int n,m,tot;
pii a[N];
bool cmp(pii &a, pii &b){
return a.se < b.se;
}
void sort_array(){
sort(a+1,a+tot+1);
int last = 0;
for(int i=1;i<=tot;i++){
if(a[i].se==inf){
if(last+1<i) sort(a+last+1,a+i,cmp);
last = i;
}
}
// for(int i=1;i<=tot;i++) {
// cerr<<a[i].fi<<" ";
// if(a[i].se!=inf) cerr<<a[i].se;
// cerr<<"\n";
// }
}
signed main(){
ios_base::sync_with_stdio(NULL);
cin.tie(NULL);
if(fopen("TASK.INP", "r")){
freopen("TASK.INP", "r", stdin);
freopen("TASK.OUT", "w", stdout);
}
cin>>n>>m;
for(int i=1;i<=n;i++) {
int x,y; cin>>x>>y;
a[++tot] = {x,y};
}
for(int i=1;i<=m;i++) cin>>a[++tot].fi, a[tot].se = inf;
sort_array();
// cerr<<'\n';
multiset<int> st;
int sz =0;
for(int i=tot;i>=1;i--){
if(a[i].se==inf) sz++;
else{
auto it = st.lower_bound(a[i].se);
if(it!=st.begin()) {
advance(it,-1);
st.erase(it);
st.insert(a[i].se);
}
else{
if(sz(st)<sz) st.insert(a[i].se);
}
}
// cerr<<i<<" "<<sz(st)<<"\n";
}
// cerr<<sz;
cout<<sz(st);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |