제출 #1232711

#제출 시각아이디문제언어결과실행 시간메모리
1232711antromancapExhibition (JOI19_ho_t2)C++20
0 / 100
0 ms840 KiB
#include <bits/stdc++.h> using namespace std; const int N = 1e5 + 1; int n, m, x[N], C[N]; pair<int, int> a[N]; int b[N]; void upd(int i, int x) { for (; i <= n; i += i & -i) b[i] = max(b[i], x); } int get(int i) { int res = 0; for (; i; i -= i & -i) res = max(res, b[i]); return res; } int main() { ios::sync_with_stdio(0); cin.tie(0); memset(b, 0xc0, 4 * N); cin >> n >> m; for (int i = 1; i <= n; i++) cin >> a[i].second >> a[i].first; sort(a + 1, a + n + 1); for (int i = 1; i <= m; i++) cin >> C[i]; sort(C + 1, C + m + 1); for (int i = 1; i <= n; i++) x[i] = lower_bound(C + 1, C + m + 1, a[i].second) - C - i; int res = 0; for (int i = n; i; i--) { upd(i, x[i]); int l = i, r = n; while (l <= r) { int mid = (l + r) >> 1; if (m - mid >= get(mid)) l = mid + 1; else r = mid - 1; } res = max(res, r - i + 1); } cout << res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...