# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101748 | 2019-03-19T20:06:17 Z | Ort | Sličice (COCI19_slicice) | C | 120 ms | 1400 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1280 KB | Output is correct |
2 | Correct | 4 ms | 1280 KB | Output is correct |
3 | Correct | 104 ms | 1400 KB | Output is correct |
4 | Correct | 102 ms | 1272 KB | Output is correct |
5 | Correct | 120 ms | 1236 KB | Output is correct |
6 | Correct | 116 ms | 1240 KB | Output is correct |
7 | Correct | 105 ms | 1208 KB | Output is correct |
8 | Correct | 104 ms | 1332 KB | Output is correct |
9 | Correct | 96 ms | 1272 KB | Output is correct |
10 | Correct | 102 ms | 1280 KB | Output is correct |