Submission #147409

#TimeUsernameProblemLanguageResultExecution timeMemory
147409ipaljakSličice (COCI19_slicice)C++14
90 / 90
62 ms1404 KiB
#include <bits/stdc++.h> using namespace std; #define TRACE(x) cerr << #x << " " << x << endl #define FOR(i, a, b) for (int i = (a); i < int(b); ++i) #define REP(i, n) FOR(i, 0, n) #define _ << " " << typedef long long llint; const int MOD = 1e9 + 7; const int MAXN = 505; int n, m, k; int p[MAXN], b[MAXN], dp[MAXN][MAXN]; int main(void) { scanf("%d%d%d", &n, &m, &k); for (int i = 0; i < n; ++i) scanf("%d", &p[i + 1]); for (int i = 0; i < m + 1; ++i) scanf("%d", &b[i]); for (int i = 1; i <= n; ++i) for (int j = 0; j <= k; ++j) for (int l = p[i]; l <= m && (l - p[i]) <= j; ++l) dp[i][j] = max(dp[i][j], dp[i - 1][j - (l - p[i])] + b[l]); printf("%d\n", dp[n][k]); return 0; }

Compilation message (stderr)

slicice.cpp: In function 'int main()':
slicice.cpp:19:8: 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:21:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &p[i + 1]);
     ~~~~~^~~~~~~~~~~~~~~~~
slicice.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d", &b[i]);
     ~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...