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
const int maxn = 10000004;
int n, k, b[maxn];
pint a[maxn];
static char buf[1 << 19]; // size : any number geq than 1024
static int idx = 0;
static int bytes = 0;
static inline int _read() {
if (!bytes || idx == bytes) {
bytes = (int)fread(buf, sizeof(buf[0]), sizeof(buf), stdin);
idx = 0;
}
return buf[idx++];
}
static inline int _readInt() {
int x = 0, s = 1;
int c = _read();
while (c <= 32) c = _read();
if (c == '-') s = -1, c = _read();
while (c > 32) x = 10 * x + (c - '0'), c = _read();
if (s < 0) x = -x;
return x;
}
int main() {
n = _readInt();
for (int i=0; i<n; i++) {
int x, y;
x = _readInt(); y = _readInt();
a[i] = pint(x+y, y-x);
}
for (int i=0; i<n; i++) {
while (k and a[b[k-1]].y <= a[i].y) k--;
if (!k or a[b[k-1]].x < a[i].x) b[k++] = i;
}
cout << k << '\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... |