Submission #101748

#TimeUsernameProblemLanguageResultExecution timeMemory
101748OrtSličice (COCI19_slicice)C11
90 / 90
120 ms1400 KiB
#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)

slicice.c: In function 'main':
slicice.c:8:2: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%d%d%d",&n,&m,&k);
  ^~~~~~~~~~~~~~~~~~~~~~~~
slicice.c:9:19: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  for(i=0;i<n;i++) scanf("%d",&sets[i]);
                   ^~~~~~~~~~~~~~~~~~~~
slicice.c:10:21: warning: ignoring return value of 'scanf', declared with attribute warn_unused_result [-Wunused-result]
  for(i=0;i<m+1;i++) scanf("%d",&values[i]);
                     ^~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...