Submission #788763

#TimeUsernameProblemLanguageResultExecution timeMemory
788763acatmeowmeowExhibition (JOI19_ho_t2)C++11
100 / 100
48 ms6356 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 1e5; int n, m, S[N + 5], V[N + 5], C[N + 5], arr[N + 5]; signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> S[i] >> V[i]; for (int i = 1; i <= m; i++) cin >> C[i]; for (int i = 1; i <= n; i++) arr[i] = i; sort(arr + 1, arr + n + 1, [&](int a, int b) { if (V[a] == V[b]) return S[a] < S[b]; else return V[a] < V[b]; }); sort(C + 1, C + m + 1); int ans = 0, index = n; for (int i = m; i >= 1; i--) { while (index && S[arr[index]] > C[i]) index--; if (!index) break; if (S[arr[index]] <= C[i]) index--, ans++; } cout << ans << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...