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;
inline int readInt() {
int x = 0;
char ch = getchar_unlocked();
bool s = 1;
while (ch < '0' || ch > '9') {
if (ch == '-') {
s = 0;
ch = getchar_unlocked();
}
}
while (ch >= '0' && ch <= '9') {
x = (x << 3) + (x << 1) + ch - '0';
ch = getchar_unlocked();
}
return s ? x : -x;
}
stack<pair<int, int>> s;
int main() {
int n = readInt();
for (int i = 0; i < n; i++) {
int x = readInt();
int y = readInt();
bool add = 1;
while (s.size()) {
int tx = s.top().first;
int ty = s.top().second;
if (x - tx <= ty - y) {
add = 0;
break;
}
if (x - tx <= y - ty) {
s.pop();
} else {
break;
}
}
if (add) {
s.push({x, y});
}
}
cout << s.size();
}
# | 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... |