Submission #1240318

#TimeUsernameProblemLanguageResultExecution timeMemory
1240318altern23Sličice (COCI19_slicice)C++20
90 / 90
43 ms2400 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long #define pii pair<ll, ll> #define fi first #define sec second #define ld long double const int MAXN = 5e2; const ll INF = 1e18; const int MOD = 1e9 + 7; const ld eps = 1e-6; ll p[MAXN + 5], b[MAXN + 5]; ll dp[MAXN + 5][MAXN + 5]; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int tc = 1; // cin >> tc; for(;tc--;){ ll N, M, K; cin >> N >> M >> K; for(int i = 1; i <= N; i++){ cin >> p[i]; } for(int i = 0; i <= M; i++){ cin >> b[i]; } ll ans = 0; for(int i = 0; i <= N; i++){ for(int j = 0; j <= K; j++) dp[i][j] = -INF; } dp[0][0] = 0; for(int i = 1; i <= N; i++){ for(int j = 0; j <= K; j++){ for(int k = p[i]; k <= M; k++){ if(j >= k - p[i]) dp[i][j] = max(dp[i][j], dp[i - 1][j - (k - p[i])] + b[k]); } ans = max(ans, dp[i][j]); } } cout << ans << "\n"; } } /* */
#Verdict Execution timeMemoryGrader output
Fetching results...