# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
147409 | 2019-08-29T13:08:45 Z | ipaljak | Sličice (COCI19_slicice) | C++14 | 62 ms | 1404 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1404 KB | Output is correct |
2 | Correct | 3 ms | 1276 KB | Output is correct |
3 | Correct | 59 ms | 1272 KB | Output is correct |
4 | Correct | 61 ms | 1264 KB | Output is correct |
5 | Correct | 60 ms | 1272 KB | Output is correct |
6 | Correct | 60 ms | 1272 KB | Output is correct |
7 | Correct | 58 ms | 1272 KB | Output is correct |
8 | Correct | 62 ms | 1304 KB | Output is correct |
9 | Correct | 59 ms | 1272 KB | Output is correct |
10 | Correct | 62 ms | 1380 KB | Output is correct |