# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100348 | pzdba | Sličice (COCI19_slicice) | C++14 | 121 ms | 1400 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 dp[501][501];
int p[501], b[501];
int main(){
int n, m, k;
scanf("%d%d%d", &n, &m, &k);
for(int i=1;i<=n;i++) scanf("%d", &p[i]);
for(int i=0;i<=m;i++) scanf("%d", &b[i]);
int ans = 0;
for(int i=1;i<=n;i++){
for(int j=0;j<=k;j++){
for(int r=0;r<=m-p[i];r++){
if(j+r <= k) dp[i][j+r] = max(dp[i][j+r], dp[i-1][j] + b[p[i]+r]);
ans = max(ans, dp[i][j+r]);
}
}
}
printf("%d\n", ans);
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |