# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
373836 | guka415 | Lightning Rod (NOI18_lightningrod) | C++14 | 2093 ms | 141740 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.
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
const int sz = 1e7 + 5;
int n;
int p[sz][2];
int mxx[sz], mny[sz];
int main() {
int xp, yp, ret = 0, mx = -2e9;
scanf("%d", &n);
for (int i = 0; i < n; i++) {
scanf("%d %d", &xp, &yp);
p[i][0] = xp + yp;
p[i][1] = xp - yp;
}
mxx[0] = p[0][0];
for (int i = 1; i < n; i++)
mxx[i] = (mxx[i - 1] < p[i][0] ? p[i][0] : mxx[i - 1]);
mny[n - 1] = p[n - 1][1];
for (int i = n - 2; i >= 0; i--)
mny[i] = (mny[i + 1] > p[i][1] ? p[i][1] : mny[i + 1]);
for (int i = 0; i < n; i++) {
bool yes = 1;
if (i && mxx[i - 1] >= p[i][0])
yes = 0;
if (i != n - 1 && mny[i + 1] <= p[i][1])
yes = 0;
ret += yes;
}
printf("%d", ret);
return 0;
}
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... |