# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
111946 | fredbr | Sličice (COCI19_slicice) | C++17 | 164 ms | 1456 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;
int const maxn = 505;
int n, m, k;
int b[maxn], p[maxn];
int dp[maxn][maxn];
int solve(int resta, int at) {
if (at == n+1) return 0;
if (dp[resta][at] >= 0) return dp[resta][at];
int& d = dp[resta][at];
d = 0;
for (int i = p[at]; i <= m and i-p[at] <= resta; i++) {
d = max(d, b[i] + solve(resta-i+p[at], at+1));
}
return d;
}
int main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
cin >> n >> m >> k;
for (int i = 1; i <= n; i++) cin >> p[i];
for (int i = 0; i <= m; i++) cin >> b[i];
memset(dp, -1, sizeof(dp));
int ans = solve(k, 1);
cout << ans << "\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |