제출 #1248996

#제출 시각아이디문제언어결과실행 시간메모리
1248996chikien2009Advertisement 2 (JOI23_ho_t2)C++20
100 / 100
619 ms21964 KiB
#include <bits/stdc++.h> using namespace std; void setup() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } struct SEGMENT_TREE { int tree[2000000]; inline SEGMENT_TREE() { fill_n(tree, 2000000, -2e9); } inline void Update(int ind, int l, int r, int x, int v) { if (r < x || x < l) { return; } if (l == r) { tree[ind] = max(tree[ind], v); return; } int m = (l + r) >> 1; Update(ind << 1, l, m, x, v); Update(ind << 1 | 1, m + 1, r, x, v); tree[ind] = max(tree[ind << 1], tree[ind << 1 | 1]); } inline int Get(int ind, int l, int r, int x, int y) { if (r < x || y < l) { return -2e9; } if (x <= l && r <= y) { return tree[ind]; } int m = (l + r) >> 1; return max(Get(ind << 1, l, m, x, y), Get(ind << 1 | 1, m + 1, r, x, y)); } } st1, st2; int n, a, b, c[500000], d, m, res; pair<int, int> p[500000]; int main() { setup(); cin >> n; res = n; for (int i = 0; i < n; ++i) { cin >> p[i].second >> p[i].first; c[i] = p[i].second; } sort(c, c + n); m = unique(c, c + n) - c; sort(p, p + n, greater<pair<int, int>>()); for (int i = 0; i < n; ++i) { d = lower_bound(c, c + m, p[i].second) - c + 1; a = st1.Get(1, 1, m, 1, d); b = st2.Get(1, 1, m, d, m); if (p[i].first + p[i].second <= a || p[i].first - p[i].second <= b) { res--; } st1.Update(1, 1, m, d, p[i].first + p[i].second); st2.Update(1, 1, m, d, p[i].first - p[i].second); } cout << res; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...