이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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 || (p1.second == p2.second && p1.first < p2.first);
});
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... |