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;
#define ll long long
#define x first
#define y second
vector<pair<ll, ll>> P;
vector<ll> C;
int dp[1002][1002];
void solve(){
int N, M;
cin>>N>>M;
P.assign(N, pair<ll, ll>());
C.assign(M, 0);
for(int i = 0; i < N; i++)
cin>>P[i].x>>P[i].y;
for(int j = 0; j < M; j++)
cin>>C[j];
sort(C.begin(), C.end());
sort(P.begin(), P.end(), [&](pair<ll, ll> p1, pair<ll, ll> p2){
return p1.second < p2.second;
});
int ans = 0;
for(int i = 0; i <= M; i++){
for(int j = 0; j <= N; j++){
if(i == 0 || j == 0) {
dp[i][j] = 0;
continue;
}
if(P[j-1].first <= C[i-1]){
dp[i][j] = dp[i-1][j-1]+1;
ans = max(dp[i][j], ans);
continue;
}
dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
ans = max(dp[i][j], ans);
}
}
cout<<ans<<endl;
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
solve();
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |