제출 #945356

#제출 시각아이디문제언어결과실행 시간메모리
945356rainboy새로운 문제 (POI13_tak)C11
30 / 100
125 ms13140 KiB
#include <stdio.h> #define N 500000 #define INF 0x3f3f3f3f unsigned int X = 12345; int rand_() { return (X *= 3) >> 1; } void sort(long long *dd, int l, int r) { while (l < r) { int i = l, j = l, k = r; long long d = dd[l + rand_() % (r - l)], tmp; while (j < k) if (dd[j] == d) j++; else if (dd[j] < d) { tmp = dd[i], dd[i] = dd[j], dd[j] = tmp; i++, j++; } else { k--; tmp = dd[j], dd[j] = dd[k], dd[k] = tmp; } sort(dd, l, i); l = k; } } int main() { static long long dd[N]; int n, i; long long m, l, x; scanf("%lld%lld%d", &m, &l, &n); for (i = 0; i < n; i++) scanf("%lld", &dd[i]); sort(dd, 0, n); x = 0; for (i = n - 1; i >= 0 && x < l; i--) { if (l - x > dd[i]) { printf("0\n"); return 0; } x += dd[i] - (l - x); } if (x < l) { printf("0\n"); return 0; } if (x >= m) { printf("%d\n", n - 1 - i); return 0; } if (i >= 0 && dd[i] >= m - l) { printf("%d\n", n - i); return 0; } i = 0; while (i < n && dd[i] < m - l) i++; if (i == n) { printf("0\n"); return 0; } n--; while (i < n) dd[i] = dd[i + 1], i++; x = 0; for (i = n - 1; i >= 0 && x < l; i--) { if (l - x > dd[i]) { printf("0\n"); return 0; } x += dd[i] - (l - x); } printf("%d\n", x < l ? 0 : n - i); return 0; }

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

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