제출 #626124

#제출 시각아이디문제언어결과실행 시간메모리
626124l_rehoExhibition (JOI19_ho_t2)C++14
50 / 100
359 ms16080 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...