이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |