# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147409 | ipaljak | Sličice (COCI19_slicice) | C++14 | 62 ms | 1404 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 <bits/stdc++.h>
using namespace std;
#define TRACE(x) cerr << #x << " " << x << endl
#define FOR(i, a, b) for (int i = (a); i < int(b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define _ << " " <<
typedef long long llint;
const int MOD = 1e9 + 7;
const int MAXN = 505;
int n, m, k;
int p[MAXN], b[MAXN], dp[MAXN][MAXN];
int main(void) {
scanf("%d%d%d", &n, &m, &k);
for (int i = 0; i < n; ++i)
scanf("%d", &p[i + 1]);
for (int i = 0; i < m + 1; ++i)
scanf("%d", &b[i]);
for (int i = 1; i <= n; ++i)
for (int j = 0; j <= k; ++j)
for (int l = p[i]; l <= m && (l - p[i]) <= j; ++l)
dp[i][j] = max(dp[i][j], dp[i - 1][j - (l - p[i])] + b[l]);
printf("%d\n", dp[n][k]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |