# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101748 | Ort | Sličice (COCI19_slicice) | C11 | 120 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<stdio.h>
#define MAX 505
int n, m, k, i, j, l;
int sets[MAX], values[MAX], dp[MAX][MAX];
int main() {
scanf("%d%d%d",&n,&m,&k);
for(i=0;i<n;i++) scanf("%d",&sets[i]);
for(i=0;i<m+1;i++) scanf("%d",&values[i]);
for(i=0;i<n;i++)
for(j=0;j<=k;j++)
for(l=0;l<=j;l++) {
if(sets[i]+j-l>m) continue;
if(i-1>=0) {if(dp[i-1][l]+values[sets[i]+j-l]>dp[i][j]) dp[i][j] = dp[i-1][l]+values[sets[i]+j-l];}
else if(values[sets[i]+j-l]>dp[i][j]) dp[i][j] = values[sets[i]+j-l];
}
printf("%d", dp[n-1][k]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |