# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548758 | usukhbaatar | Lightning Rod (NOI18_lightningrod) | C++14 | 745 ms | 79688 KiB |
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 <stack>
#include <cstdio>
using namespace std;
stack<pair<int, int>> s;
void fastscan(int &a) {
a = 0;
char c = getchar();
for (; (c>47 && c<58); c=getchar())
a = a *10 + c - 48;
}
int main() {
int n, x, y;
scanf("%d\n", &n);
for (int i = 0; i < n; i++) {
fastscan(x); fastscan(y);
int l = x - y;
int r = x + y;
if (!s.empty()) {
if (s.top().first <= l && r <= s.top().second)
continue;
}
while (!s.empty() && l <= s.top().first && s.top().second <= r) s.pop();
s.push({l, r});
}
printf("%d\n", s.size());
}
Compilation message (stderr)
# | 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... |