Submission #340976

#TimeUsernameProblemLanguageResultExecution timeMemory
340976ijxjdjdExhibition (JOI19_ho_t2)C++14
100 / 100
158 ms4972 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; const int MAXN = (int)(2e5)+5; int dp[MAXN]; int main() { int N, M; cin >> N >> M; vector<pair<int, int>> F(N); vector<int> C(M); for (int i = 0; i < N; i++) { int f, s; cin >> f >> s; F[i] = {s, f}; } for (int i = 0; i < M; i++) { cin >> C[i]; } sort(F.rbegin(), F.rend()); sort(C.rbegin(), C.rend()); dp[0] = (F[0].second <= C[0]); int curMax = dp[0]; for (int i = 1; i < N; i++) { int low = 0; int high = M-1; while (low < high) { int mid = (low + high+1)/2; if (C[mid] >= F[i].second) { low = mid; } else { high = mid-1; } } dp[i] = min(curMax+1, low+1); if (C[0] < F[i].second) { dp[i] = 0; } curMax = max(dp[i], curMax); } cout << curMax << '\n'; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...