답안 #944533

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
944533 2024-03-12T21:32:31 Z rainboy 사냥꾼 (KOI13_hunter) C
100 / 100
45 ms 3416 KB
#include <stdio.h>

#define N	100000
#define INF	0x3f3f3f3f

int min(int a, int b) { return a < b ? a : b; }

unsigned int X = 12345;

int rand_() {
	return (X *= 3) >> 1;
}

void sort(int *xx, int l, int r) {
	while (l < r) {
		int i = l, j = l, k = r, x = xx[l + rand_() % (r - l)], tmp;

		while (j < k)
			if (xx[j] == x)
				j++;
			else if (xx[j] < x) {
				tmp = xx[i], xx[i] = xx[j], xx[j] = tmp;
				i++, j++;
			} else {
				k--;
				tmp = xx[j], xx[j] = xx[k], xx[k] = tmp;
			}
		sort(xx, l, i);
		l = k;
	}
}

int main() {
	static int xx[N];
	int n, m, l, i, lower, upper, cnt;

	scanf("%d%d%d", &n, &m, &l);
	for (i = 0; i < n; i++)
		scanf("%d", &xx[i]);
	sort(xx, 0, n);
	cnt = 0;
	while (m--) {
		int x, y;

		scanf("%d%d", &x, &y);
		lower = -1, upper = n;
		while (upper - lower > 1) {
			i = (lower + upper) / 2;
			if (xx[i] <= x)
				lower = i;
			else
				upper = i;
		}
		if (min(lower == -1 ? INF : x - xx[lower], upper == n ? INF : xx[upper] - x) + y <= l)
			cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}

Compilation message

hunter.c: In function 'main':
hunter.c:37:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |  scanf("%d%d%d", &n, &m, &l);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
hunter.c:39:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |   scanf("%d", &xx[i]);
      |   ^~~~~~~~~~~~~~~~~~~
hunter.c:45:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   45 |   scanf("%d%d", &x, &y);
      |   ^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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
5 Correct 0 ms 424 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 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
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 432 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 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 344 KB Output is correct
4 Correct 1 ms 600 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 2 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 2004 KB Output is correct
2 Correct 30 ms 2392 KB Output is correct
3 Correct 35 ms 2652 KB Output is correct
4 Correct 28 ms 2388 KB Output is correct
5 Correct 45 ms 3248 KB Output is correct
6 Correct 42 ms 3156 KB Output is correct
7 Correct 43 ms 3416 KB Output is correct
8 Correct 33 ms 2900 KB Output is correct
9 Correct 44 ms 3412 KB Output is correct
10 Correct 42 ms 3416 KB Output is correct