# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1106388 | SalihSahin | Sličice (COCI19_slicice) | C++14 | 64 ms | 2432 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |