Submission #1126432

#TimeUsernameProblemLanguageResultExecution timeMemory
1126432dubabubaExhibition (JOI19_ho_t2)C++20
100 / 100
308 ms25680 KiB
#include <bits/stdc++.h> using namespace std; #define int long long typedef pair<int, int> pii; #define ff first #define ss second #define MP make_pair const int inf = 1e18 + 10; const int mxn = 2e5 + 10; int s[mxn], v[mxn], c[mxn]; int val[mxn]; int n, m, k = 1; int32_t main() { cin >> n >> m; map<int, int> mp; for(int i = 1; i <= n; i++) { cin >> s[i] >> v[i]; mp[s[i]]; } for(int i = 1; i <= m; i++) { cin >> c[i]; mp[c[i]]; } priority_queue<pii> pq; multiset<pii> ms; for(int i = 1; i <= n; i++) { pq.push(MP(s[i], v[i])); ms.insert(MP(v[i], s[i])); } for(int i = 1; i <= m; i++) { pq.push(MP(c[i], inf)); } int ans = 0; while(pq.size()) { if(ms.size() == 0) break; int SIZE = pq.top().ff; int val = pq.top().ss; pq.pop(); if(val < inf) { auto it = ms.find(MP(val, SIZE)); if(it == ms.end()) continue; ms.erase(it); } else { auto it = ms.end(); it--; ms.erase(it); ans++; } } cout << ans << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...