Submission #945347

#TimeUsernameProblemLanguageResultExecution timeMemory
945347rainboyTaxis (POI13_tak)C11
10 / 100
119 ms11612 KiB
#include <stdio.h>

#define N	500000

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, l, r, i, k;

	scanf("%d%d%d", &r, &l, &n), r -= l;
	for (i = 0; i < n; i++)
		scanf("%d", &xx[i]);
	sort(xx, 0, n);
	k = 0;
	if (r > 0) {
		i = 0;
		while (i < n && xx[i] < r)
			i++;
		if (i == n) {
			printf("0\n");
			return 0;
		}
		k++;
		n--;
		while (i < n)
			xx[i] = xx[i + 1], i++;
	}
	for (i = n - 1; i >= 0 && l > 0; i--) {
		if (l > xx[i]) {
			printf("0\n");
			return 0;
		}
		l -= xx[i] - l, k++;
	}
	printf("%d\n", k);
	return 0;
}

Compilation message (stderr)

tak.c: In function 'main':
tak.c:34:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   34 |  scanf("%d%d%d", &r, &l, &n), r -= l;
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
tak.c:36:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |   scanf("%d", &xx[i]);
      |   ^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...