Submission #857429

# Submission time Handle Problem Language Result Execution time Memory
857429 2023-10-06T07:51:17 Z CMJ A Huge Tower (CEOI10_tower) C
100 / 100
122 ms 8916 KB
#include <stdio.h>
#include <stdlib.h>

int int_cmp(const void *a, const void *b)
{
	return (*((int *)a)) - (*((int *)b));
}

int b[1000000];

#define MOD 1000000009

int main()
{
	int n, d;
	scanf("%d %d\n", &n, &d);
	long long int sol = 1;

	for(int i = 0; i < n; i++) {
		scanf("%d", b + i);
	}

	qsort(b, n, sizeof(int), int_cmp);

	int l = 0, r = 0;
	while(l < n) {
		while((r < n) && (b[r] <= b[l] + d))
			r++;
		sol = (sol * (r - l)) % MOD;
		l++;
	}
	printf("%d\n", sol);
}

Compilation message

tower.c: In function 'main':
tower.c:32:11: warning: format '%d' expects argument of type 'int', but argument 2 has type 'long long int' [-Wformat=]
   32 |  printf("%d\n", sol);
      |          ~^     ~~~
      |           |     |
      |           int   long long int
      |          %lld
tower.c:16:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   16 |  scanf("%d %d\n", &n, &d);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~
tower.c:20:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   scanf("%d", b + i);
      |   ^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 600 KB Output is correct
2 Correct 9 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 48 ms 2140 KB Output is correct
2 Correct 47 ms 3668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 105 ms 5968 KB Output is correct
2 Correct 122 ms 8916 KB Output is correct