Submission #146986

#TimeUsernameProblemLanguageResultExecution timeMemory
146986jun6873Lightning Rod (NOI18_lightningrod)C++11
7 / 100
2060 ms156500 KiB
#include <bits/stdc++.h> using namespace std; using lint = long long; using pint = pair<lint, lint>; #define x first #define y second int n, k; pint a[10000004], c[10000004]; int ccw(pint a, pint b, pint c) { lint k = a.x*b.y + b.x*c.y + c.x*a.y - b.x*a.y - c.x*b.y - a.x*c.y; if (k>0) return 1; if (k<0) return -1; return 0; } int main() { ios::sync_with_stdio(0); cin.tie(0); cin >> n; for (int i=0; i<n; i++) { int x, y; cin >> x >> y; a[i] = pint(x+y, y-x); } sort(a, a+n); c[k++] = a[0]; for (int i=1; i<n; i++) { while (k>=2 and ccw(c[k-2], c[k-1], a[i]) >= 0) k--; c[k++] = a[i]; } int ans = k; for (int i=0; i+1<k; i++) if (c[i].y <= c[i+1].y or c[i].x >= c[i+1].x) ans--; cout << ans << '\n'; }
#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...