제출 #1315541

#제출 시각아이디문제언어결과실행 시간메모리
1315541chithanhnguyenLightning Rod (NOI18_lightningrod)C++20
66 / 100
1098 ms78724 KiB
/* Author: Nguyen Chi Thanh - High School for the Gifted - VNU.HCM (i2528) */ #include <bits/stdc++.h> using namespace std; // #define int long long #define ull unsigned long long #define ld long double #define pii pair<int, int> #define fi first #define se second #define __builtin_popcount __builtin_popcountll #define all(x) (x).begin(), (x).end() #define BIT(x, i) (((x) >> (i)) & 1) #define MASK(x) ((1ll << (x))) #define debug(a, l, r) for (int _i = (l); _i <= (r); ++_i) cout << (a)[_i] << ' '; cout << '\n'; const int MAXN = 1e7 + 5; int n; pii points[MAXN]; void init() { cin >> n; for (int i = 1; i <= n; ++i) { int x, y; cin >> x >> y; points[i] = {x + y, x - y}; } } void solve() { sort(points + 1, points + n + 1, [](pii &x, pii &y) { if (x.fi == y.fi) return x.se > y.se; return x.fi < y.fi; }); vector<int> st; for (int i = 1; i <= n; ++i) { pii p = points[i]; while (!st.empty() && p.se <= st.back()) st.pop_back(); st.push_back(p.se); } cout << (int)st.size(); } signed main() { #ifdef NCTHANH freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout); #endif ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr); init(); solve(); 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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...