# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
218076 | KoalaMuch | Exhibition (JOI19_ho_t2) | C++14 | 5 ms | 384 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;
const int N = 1e5+5;
struct A
{
int sz,v;
bool operator<(const A&o)const
{
if(v!=o.v) return v<o.v;
return sz<o.sz;
}
};
A a[N];
int b[N];
int dp[N];
int main()
{
int n,m;
scanf("%d %d",&n,&m);
for(int i=1;i<=n;i++) scanf("%d %d",&a[i].sz,&a[i].v);
for(int i=1;i<=m;i++) scanf("%d",&b[i]);
sort(a+1,a+n+1); sort(b+1,b+m+1);
int l = 0,r = n;
while(l<r)
{
int mid = (l+r+1) >> 1,len = 0;
for(int i=1;i<=n;i++)
{
int idx = upper_bound(dp,dp+len,a[i].sz)-dp;
if(a[i].sz<=b[m-mid+idx+1])
{
if(idx==len) ++len;
dp[idx] = a[i].sz;
}
}
if(len>=mid) l=mid;
else r=mid-1;
}
printf("%d\n",l);
return 0;
}
/*
3 4
10 20
5 1
3 5
4 6 10 4
8 8
508917604 35617051
501958939 840246141
485338402 32896484
957730250 357542366
904165504 137209882
684085683 775621730
552953629 20004459
125090903 607302990
433255278
979756183
28423637
856448848
276518245
314201319
666094038
149542543
*/
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... |