제출 #826230

#제출 시각아이디문제언어결과실행 시간메모리
826230rainboyTable Tennis (info1cup20_tabletennis)C11
9 / 100
3047 ms2496 KiB
#include <stdio.h> #define N 150000 #define K 400 #define M ((K + 1) * (K + 1)) int max(int a, int b) { return a > b ? a : b; } unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } void sort(int *aa, int l, int r) { while (l < r) { int i = l, j = l, k = r, a = aa[l + rand_() % (r - l)], tmp; while (j < k) if (aa[j] == a) j++; else if (aa[j] < a) { tmp = aa[i], aa[i] = aa[j], aa[j] = tmp; i++, j++; } else { k--; tmp = aa[j], aa[j] = aa[k], aa[k] = tmp; } sort(aa, l, i); l = k; } } int main() { static int aa[N + K], ss[M], kk[M]; static char used[M]; int n, m, k, h, i, j, s; scanf("%d%d", &n, &k); for (i = 0; i < n + k; i++) scanf("%d", &aa[i]); m = 0; for (i = 0; i <= k; i++) for (j = n + k - 1; j > i && j >= n - 1; j--) ss[m++] = aa[i] + aa[j]; sort(ss, 0, m); for (i = 0; i < n; i++) for (j = max(n - 1 - i, i + 1), h = 0; i + j <= n - 1 + k * 2; j++) { s = aa[i] + aa[j]; while (h < m && ss[h] < s) h++; if (h < m && ss[h] == s) kk[h]++; } for (h = 0; h < m; h++) if (kk[h] >= n / 2) { for (i = 0, j = n + k - 1, k = n / 2; i < j && k > 0; i++) { while (i < j && aa[i] + aa[j] > ss[h]) j--; if (i < j && aa[i] + aa[j] == ss[h]) used[i] = used[j] = 1, k--; } for (i = 0; i < n + k; i++) if (used[i]) printf("%d ", aa[i]); printf("\n"); return 0; } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

tabletennis.c: In function 'main':
tabletennis.c:39:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   39 |  scanf("%d%d", &n, &k);
      |  ^~~~~~~~~~~~~~~~~~~~~
tabletennis.c:41:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   41 |   scanf("%d", &aa[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...