Submission #334942

#TimeUsernameProblemLanguageResultExecution timeMemory
334942ronnithSličice (COCI19_slicice)C++14
90 / 90
70 ms1388 KiB
#include <bits/stdc++.h> #define trav(a, b) for(auto a : b) #define mk make_pair #define f first #define s second #define vi vector<int> #define pb push_back using namespace std; int main(){ // ios::sync_with_stdio(0);cin.tie(0);cout.tie(0); int n, m, k; scanf("%d%d%d", &n, &m, &k); int p[n], b[m + 1]; for(int i = 0;i < n;i ++)scanf("%d", &p[i]); for(int i = 0;i < m + 1;i ++)scanf("%d", &b[i]); int dp[n][k + 1]; for(int i = 0;i < n;i ++){ for(int j = 0;j <= k;j ++){ dp[i][j] = 0; if(i == 0){ int nw = min(j + p[i], m); dp[i][j] = b[nw]; } else { for(int K = p[i];K - p[i] <= j and K <= m;K ++){ dp[i][j] = max(dp[i][j], b[K] + dp[i - 1][j - (K - p[i])]); } } } } printf("%d\n", dp[n - 1][k]); return 0; }

Compilation message (stderr)

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