이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll n,q;
struct dt{
ll s,v;
};
ll b[1000006],d,maxs=0;
bool cmp(dt x,dt y)
{
if(x.v<y.v)return true;
if(x.v==y.v)
{
return x.s<y.s;
}
return false;
}
dt a[1000006];
void tinh(ll x,ll y,ll z)
{
if(y>n||x>q)return;
if(a[y].s<=b[x]&&a[y].v>=z)
{
ll t=z;
z=a[y].v;
d++;
maxs=max(maxs,d);
//cout<<a[y].s<<" "<<b[x]<<"\n";
tinh(x+1,y+1,z);
d--;
z=t;
}
if(a[y].v<z)
tinh(x,y+1,z);
if(a[y].s>b[x])
tinh(x+1,y,z);
}
int main()
{
cin>>n>>q;
for(ll i=1;i<=n;i++)
cin>>a[i].s>>a[i].v;
sort(a+1,a+n+1,cmp);
for(ll i=1;i<=q;i++)
cin>>b[i];
sort(b+1,b+q+1);
for(ll i=1;i<=n;i++)
tinh(1,i,0);
cout<<maxs;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |