Submission #175682

#TimeUsernameProblemLanguageResultExecution timeMemory
175682cheissmartExhibition (JOI19_ho_t2)C++14
100 / 100
930 ms9080 KiB
#include <bits/stdc++.h> #define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0); #define F first #define S second #define V vector #define PB push_back #define MP make_pair #define EB emplace_back #define ALL(v) (v).begin(), (v).end() #define debug(x) cerr << #x << " is " << x << endl using namespace std; typedef long long ll; typedef pair<int, int> pi; typedef V<int> vi; const int INF = 1e9 + 7, N = 100005; pi a[N]; int c[N]; int n, m; bool ok(int mid) { int lst = -1; multiset<int> s; for(int i = m - mid, j = 0; i < m; i++) { while(j < n && a[j].F <= c[i]) { s.insert(a[j].S); j++; } auto it = s.lower_bound(lst); if(it == s.end()) return false; lst = *it; s.erase(it); } return true; } signed main() { IO_OP; cin >> n >> m; for(int i=0;i<n;i++) cin >> a[i].F >> a[i].S; sort(a, a+n); for(int i=0;i<m;i++) cin >> c[i]; sort(c, c+m); int l = 0, r = m; while(l <= r) { int mid = (l + r) / 2; if(ok(mid)) l = mid + 1; else r = mid - 1; } cout << r << endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...