This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |