제출 #705527

#제출 시각아이디문제언어결과실행 시간메모리
705527rainboyStove (JOI18_stove)C11
100 / 100
25 ms1616 KiB
#include <stdio.h> #define N 100000 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]; int n, k, i, ans; scanf("%d%d", &n, &k), k = n - k; for (i = 0; i < n; i++) scanf("%d", &aa[i]); for (i = n - 1; i > 0; i--) aa[i] -= aa[i - 1] + 1; sort(aa, 1, n); ans = n; for (i = 1; i <= k; i++) ans += aa[i]; printf("%d\n", ans); return 0; }

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

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