Submission #481407

#TimeUsernameProblemLanguageResultExecution timeMemory
481407rainboyHolding (COCI20_holding)C11
110 / 110
49 ms4172 KiB
#include <stdio.h> #include <string.h> #define N 100 #define K 10000 #define INF 0x3f3f3f3f int abs_(int a) { return a > 0 ? a : -a; } int min(int a, int b) { return a < b ? a : b; } int main() { static int aa[N], dp[N + 1][K + 1]; int n, l, r, k, i, c, s, ans; scanf("%d%d%d%d", &n, &l, &r, &k), l--, r--; for (i = 0; i < n; i++) scanf("%d", &aa[i]); for (c = 0; c <= n; c++) memset(dp[c], 0x3f, (k + 1) * sizeof *dp[c]); dp[0][0] = 0; for (i = 0; i < n; i++) { for (c = r - l; c >= 0; c--) { int d = abs_(i - (l + c)); for (s = 0; s + d <= k; s++) dp[c + 1][s + d] = min(dp[c + 1][s + d], dp[c][s] + aa[i]); } } c = r - l + 1; ans = INF; for (s = 0; s <= k; s++) ans = min(ans, dp[c][s]); printf("%d\n", ans); return 0; }

Compilation message (stderr)

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