Submission #100348

#TimeUsernameProblemLanguageResultExecution timeMemory
100348pzdbaSličice (COCI19_slicice)C++14
90 / 90
121 ms1400 KiB
#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)

slicice.cpp: In function 'int main()':
slicice.cpp:7:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &n, &m, &k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~
slicice.cpp:8:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=1;i<=n;i++) scanf("%d", &p[i]);
                           ~~~~~^~~~~~~~~~~~~
slicice.cpp:9:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     for(int i=0;i<=m;i++) scanf("%d", &b[i]);
                           ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...