# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
944403 |
2024-03-12T16:56:38 Z |
rainboy |
고기잡이 (KOI13_fish) |
C |
|
1 ms |
348 KB |
#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];
d = l - (xx[ii[j]] - xx[ii[i]]);
jj[h] = ii[j];
for (g = 0, h = 0; g < j - i; g++) {
while (h < j - i && yy[jj[h]] - yy[jj[g]] <= d)
h++;
ans = max(ans, h - g);
}
}
printf("%d\n", ans);
return 0;
}
Compilation message
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 |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |