제출 #1296734

#제출 시각아이디문제언어결과실행 시간메모리
1296734florescentExhibition (JOI19_ho_t2)C++20
100 / 100
377 ms7480 KiB
//STRIKER! #include <iostream> #include <vector> #include <algorithm> #include <string> #include <map> #include <set> #include <unordered_map> #include <cmath> #include <queue> #include <iomanip> using namespace std; #define int int64_t #define pb push_back #define speed cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false); #define all(a) a.begin(), a.end() #define sz(a) ((int)a.size()) int n, m; vector<pair<int, int>> a; vector<int> sizm; bool check(int mid) { multiset<int> st; int j = 0; int lst = -1; for (int i = m - mid; i < m; i++) { while (j < n and a[j].first <= sizm[i]) { st.insert(a[j].second); j++; } auto it = st.lower_bound(lst); if (it == st.end()) { return 0; } lst = *it; st.erase(it); } return 1; } void sol() { cin >> n >> m; a.resize(n); sizm.resize(m); for (int i = 0; i < n; i++) { cin >> a[i].first >> a[i].second; } sort(all(a)); for (int i = 0; i < m; i++) { cin >> sizm[i]; } sort(all(sizm)); int l = 0, r = min(m, n), ans = 0; while (l <= r) { int mid = (l + r) / 2; if (check(mid)) { ans = mid; l = mid + 1; } else { r = mid - 1; } } cout << ans; } int32_t main() { speed; int t = 1; //cin >> t; while (t--) { sol(); } return 0; } //freopen("name", "r", stdin); //freopen("name", "w", stdout);
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...