# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
479396 | rainboy | Sličice (COCI19_slicice) | C11 | 164 ms | 324 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <stdio.h>
#include <string.h>
#define N 500
#define M 500
#define K 500
int max(int a, int b) { return a > b ? a : b; }
int main() {
static int aa[N], bb[M + 1], dp[K + 1];
int n, m, k, i, j, s, c;
scanf("%d%d%d", &n, &m, &k);
for (i = 0; i < n; i++)
scanf("%d", &aa[i]);
for (j = 0; j <= m; j++)
scanf("%d", &bb[j]);
memset(dp, -1, (k + 1) * sizeof *dp), dp[0] = 0;
for (i = 0; i < n; i++)
for (s = k; s >= 0; s--)
for (c = 0; aa[i] + c <= m && c <= s; c++)
if (dp[s - c] != -1)
dp[s] = max(dp[s], dp[s - c] + bb[aa[i] + c]);
printf("%d\n", dp[k]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |