답안 #944404

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
944404 2024-03-12T16:57:43 Z rainboy 고기잡이 (KOI13_fish) C
18 / 18
1 ms 420 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];
			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

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]);
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 420 KB Output is correct
4 Correct 0 ms 416 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct