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 100
int max(int a, int b) { return a > b ? a : b; }
unsigned int X = 12345;
int rand_() {
return (X *= 3) >> 1;
}
int xx[N], yy[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)
if (xx[ii[j]] == xx[i_])
j++;
else if (xx[ii[j]] < xx[i_]) {
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], jj[N];
int n, l, d, g, h, i, j, ans;
scanf("%*d%d%d", &l, &n), l /= 2;
for (i = 0; i < n; i++)
scanf("%d%d", &xx[i], &yy[i]);
for (i = 0; i < n; i++)
ii[i] = i;
sort(ii, 0, n);
ans = 0;
for (i = 0; i < n; i++)
for (j = i; j < n && xx[ii[j]] - xx[ii[i]] <= l; j++) {
for (h = j - i; h > 0 && yy[jj[h - 1]] > yy[ii[j]]; h--)
jj[h] = jj[h - 1];
jj[h] = ii[j];
d = l - (xx[ii[j]] - xx[ii[i]]);
for (g = 0, h = 0; g < j - i + 1; g++) {
while (h < j - i + 1 && yy[jj[h]] - yy[jj[g]] <= d)
h++;
ans = max(ans, h - g);
}
}
printf("%d\n", ans);
return 0;
}
Compilation message (stderr)
fish.c: In function 'main':
fish.c:38:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
38 | scanf("%*d%d%d", &l, &n), l /= 2;
| ^~~~~~~~~~~~~~~~~~~~~~~~
fish.c:40:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
40 | scanf("%d%d", &xx[i], &yy[i]);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# | 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... |