# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
133037 | dantoh000 | Exhibition (JOI19_ho_t2) | C++14 | 2 ms | 632 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
bool cmp(ii a, ii b){
if (a.second != b.second) return a.second < b.second;
else return a.first<b.first;
}
int fw[100005];
int n;
void up(int x, int nv){
//printf("up %d %d\n",x,nv);
while (x <= n){
fw[x] = max(fw[x],nv);
x += (x)&(-x);
}
}
int rmq(int x){
//printf("quering %d\n",x);
int ans = 0;
while (x){
ans = max(ans,fw[x]);
x -= (x)&(-x);
}
return ans;
}
int main(){
memset(fw,0,sizeof(fw));
int m;
scanf("%d%d",&n,&m);
ii a[n];
for (int i = 0; i < n; i++){
scanf("%d%d",&a[i].first,&a[i].second);
}
sort(a,a+n,cmp);
int b[m];
for (int i =0 ; i<m; i++) scanf("%d",&b[i]);
sort(b,b+m);
ii h[n];
for (int i = 0; i < n; i++) h[i] = ii(a[i].first,i+1);
sort(h,h+n);
int ans[n+1]; memset(ans,0,sizeof(ans));
int cur = 0;
for (int i = 0; i < m; i++){
for (int j = 0; j < cur; j++){
ans[h[j].second] = rmq(h[j].second-1) + 1;
}
while (h[cur].first <= b[i] && cur < n){
ans[h[cur].second] = rmq(h[cur].second-1) + 1;
cur++;
}
for (int last = 0; last < cur; last++){
up(h[last].second,ans[h[last].second]);
last++;
}
for (int j = 1; j <= n; j++){
//printf("%d ",ans[j]);
}
//printf("\n");
}
int kk = 0;
for (int i = 1; i <= n;i++ ){
kk = max(ans[i],kk);
}
printf("%d",kk);
}
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... |