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 <stdio.h>
#define N 10000000
#define INF 0x3f3f3f3f
unsigned int X = 12345;
int rand_() {
return (X *= 3) >> 1;
}
int ll[N], rr[N];
void sort(int *ii, int l, int r) {
while (l < r) {
int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;
while (j < k) {
int c = ll[ii[j]] != ll[i_] ? ll[ii[j]] - ll[i_] : rr[i_] - rr[ii[j]];
if (c == 0)
j++;
else if (c < 0) {
tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
i++, j++;
} else {
k--;
tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
}
}
sort(ii, l, i);
l = k;
}
}
int main() {
static int ii[N];
int n, i, x, y, r, cnt;
scanf("%d", &n);
for (i = 0; i < n; i++) {
scanf("%d%d", &x, &y);
ll[i] = x - y, rr[i] = x + y;
}
for (i = 0; i < n; i++)
ii[i] = i;
sort(ii, 0, n);
r = -INF, cnt = 0;
for (i = 0; i < n; i++)
if (r < rr[ii[i]])
r = rr[ii[i]], cnt++;
printf("%d\n", cnt);
return 0;
}
Compilation message (stderr)
lightningrod.c: In function 'main':
lightningrod.c:40:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | scanf("%d", &n);
| ^~~~~~~~~~~~~~~
lightningrod.c:42:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
42 | scanf("%d%d", &x, &y);
| ^~~~~~~~~~~~~~~~~~~~~
# | 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... |