제출 #704724

#제출 시각아이디문제언어결과실행 시간메모리
704724rainboy오렌지 출하 (JOI16_ho_t1)C11
100 / 100
49 ms712 KiB
#include <stdio.h> #include <string.h> #define N 20000 #define INF 0x3f3f3f3f3f3f3f3fLL long long min(long long a, long long b) { return a < b ? a : b; } long long max(long long a, long long b) { return a > b ? a : b; } int main() { static int aa[N]; static long long dp[N + 1]; int n, m, c, i, j; long long mn, mx; scanf("%d%d%d", &n, &m, &c); for (i = 0; i < n; i++) scanf("%d", &aa[i]); memset(dp, 0x3f, (n + 1) * sizeof *dp), dp[0] = 0; for (i = 0; i < n; i++) { mn = INF, mx = 0; for (j = i + 1; j <= n && j - i <= m; j++) { mn = min(mn, aa[j - 1]), mx = max(mx, aa[j - 1]); dp[j] = min(dp[j], dp[i] + (mx - mn) * (j - i) + c); } } printf("%lld\n", dp[n]); return 0; }

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

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