Submission #1106388

#TimeUsernameProblemLanguageResultExecution timeMemory
1106388SalihSahinSličice (COCI19_slicice)C++14
90 / 90
64 ms2432 KiB
#include <bits/stdc++.h> #define pb push_back #define int long long using namespace std; const int mod = 1e9 + 7; const int inf = 1e17; const int N = 2e5+5; int32_t main(){ cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(false); int n, m, k; cin>>n>>m>>k; vector<int> p(n), b(m+1); for(int i = 0; i < n; i++){ cin>>p[i]; } for(int i = 0; i <= m; i++){ cin>>b[i]; } vector<vector<int> > dp(n+1, vector<int>(k+1, -inf)); dp[0][0] = 0; for(int i = 0; i < n; i++){ for(int j = 0; j <= k; j++){ for(int pre = 0; pre <= j; pre++){ dp[i+1][j] = max(dp[i+1][j], dp[i][pre] + b[min(p[i] + (j - pre), m)]); } } } cout<<dp[n][k]<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...