이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
struct Point {
int x, y;
Point() {}
Point(int _x, int _y) {
x = _x; y = _y;
}
};
const int N = 1e7+7;
int numPoint, sz;
Point points[N], st[N];
bool inside(const Point &a, const Point &b) { // check if a is inside b
return abs(b.x - a.x) <= b.y - a.y;
}
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
#ifdef NHPHUCQT
freopen("demo.inp", "r", stdin);
freopen("demo.out", "w", stdout);
#endif // NHPHUCQT
cin >> numPoint;
for (int i = 0; i < numPoint; ++i) {
cin >> points[i].x >> points[i].y;
}
for (int i = 0, cnt = 0, maxs = 0; i < numPoint; ++i) {
cnt++; maxs = max(maxs, points[i].y);
if (i + 1 == numPoint || points[i].x != points[i+1].x) {
while (sz > 0 && inside(st[sz-1], Point(points[i].x, maxs))) {
sz--;
}
if (sz == 0 || !inside(Point(points[i].x, maxs), st[sz-1])) {
st[sz++] = points[i];
}
cnt = maxs = 0;
}
}
cout << sz;
return 0;
}
# | 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... |