# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
111946 |
2019-05-16T22:33:35 Z |
fredbr |
Sličice (COCI19_slicice) |
C++17 |
|
164 ms |
1456 KB |
#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 |
1 |
Correct |
3 ms |
1408 KB |
Output is correct |
2 |
Correct |
3 ms |
1408 KB |
Output is correct |
3 |
Correct |
143 ms |
1280 KB |
Output is correct |
4 |
Correct |
150 ms |
1456 KB |
Output is correct |
5 |
Correct |
146 ms |
1452 KB |
Output is correct |
6 |
Correct |
164 ms |
1452 KB |
Output is correct |
7 |
Correct |
131 ms |
1408 KB |
Output is correct |
8 |
Correct |
164 ms |
1456 KB |
Output is correct |
9 |
Correct |
135 ms |
1456 KB |
Output is correct |
10 |
Correct |
135 ms |
1408 KB |
Output is correct |