Submission #234921

#TimeUsernameProblemLanguageResultExecution timeMemory
234921davitmargExhibition (JOI19_ho_t2)C++17
0 / 100
5 ms384 KiB
/*DavitMarg*/ #include <iostream> #include <algorithm> #include <cmath> #include <vector> #include <string> #include <cstring> #include <map> #include <unordered_map> #include <set> #include <queue> #include <iomanip> #include <bitset> #include <stack> #include <cassert> #include <iterator> #include <fstream> #define mod 1000000007ll #define LL long long #define LD long double #define MP make_pair #define PB push_back #define all(v) v.begin(), v.end() #define fastIO ios::sync_with_stdio(false); cin.tie(0) using namespace std; const int N = 100005; int n,k,c[N]; pair<int, int> a[N]; bool check(int x) { multiset<int> s; for (int i = 1; i <= k; i++) s.insert(c[i]); vector<pair<int,int>> b; for (int i = 1; i <= x; i++) b.push_back(a[i]); sort(all(b), [](pair<int, int> a, pair<int, int> b) { if (a.second != b.second) return a.second < b.second; return a < b; }); for (int i = 0; i < x; i++) { if (i) b[i].first = max(b[i].first, b[i - 1].first); auto it = s.lower_bound(b[i].first); if (it == s.end()) return 0; s.erase(it); } return 1; } int main() { fastIO; cin >> n >> k; for (int i = 1; i <= n; i++) cin >> a[i].first >> a[i].second; for (int i = 1; i <= k; i++) cin >> c[i]; sort(a + 1, a + 1 + n); int l = 0, r = k, m, ans = 0; while (l <= r) { m = (l + r) / 2; if (check(m)) { ans = m; l = m + 1; } else r = m - 1; } cout << ans << endl; return 0; } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...