# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
111946 | fredbr | Sličice (COCI19_slicice) | C++17 | 164 ms | 1456 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |