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>
#define ff first
#define ss second
using namespace std;
int n,m,c[100005],i,j,dp[1005][1005];
pair<int,int> p[100005];
bool cmp(pair<int,int> a,pair<int,int> b){
if(a.ss==b.ss) return a.ff<b.ff;
return a.ss<b.ss;
}
int main(){
cin >> n >> m;
for(i=1;i<=n;i++){
cin >> p[i].ff >> p[i].ss;
}
for(i=1;i<=m;i++){
cin >> c[i];
}
sort(p+1,p+n+1,cmp);
sort(c+1,c+m+1);
for(i=1;i<=m;i++){
for(j=1;j<=n;j++){
if(c[i]>=p[j].ff) dp[i][j]=dp[i-1][j-1]+1;
else dp[i][j]=dp[i][j-1];
}
}
cout << dp[m][n];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |