Submission #944533

#TimeUsernameProblemLanguageResultExecution timeMemory
944533rainboy사냥꾼 (KOI13_hunter)C11
100 / 100
45 ms3416 KiB
#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 (stderr)

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);
      |   ^~~~~~~~~~~~~~~~~~~~~
#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...