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;
signed main() {
int n,m; cin>>n>>m;
vector<pair<int,int>>v(n);
for(auto &z : v) {
cin>>z.second>>z.first;
}
sort(v.begin(),v.end());
vector<int>c(m);
for(auto &z : c) {
cin>>z;
}
sort(c.begin(),c.end());
int dp[n+5][m+5];
for(int i = 0 ; i <= n ; i++) {
for(int j = 0 ; j <= m ; j++) {
dp[i][j] = 0;
}
}
int ans = 0;
for(int i = 1 ; i <= n ; i++) {
for(int j = 1 ; j <= m ; j++) {
dp[i][j] = dp[i][j-1];
if(v[i-1].second <= c[j-1])
dp[i][j] = max(dp[i][j], dp[i-1][j-1] + 1);
ans = max(ans, dp[i][j]);
}
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |