# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1276646 | SmuggingSpun | Sličice (COCI19_slicice) | C++20 | 36 ms | 584 KiB |
#include<bits/stdc++.h>
#define taskname "C"
using namespace std;
template<class T>void maximize(T& a, T b){
if(a < b){
a = b;
}
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
if(fopen(taskname".inp", "r")){
freopen(taskname".inp", "r", stdin);
}
int n, m, k;
cin >> n >> m >> k;
vector<int>p(n), b(m + 1);
for(int& x : p){
cin >> x;
}
for(int& x : b){
cin >> x;
}
vector<int>dp(k + 1, 0);
for(int& x : p){
for(int i = k; i > 0; i--){
for(int j = min(i, m - x); j > 0; j--){
maximize(dp[i], dp[i - j] + b[x + j] - b[x]);
}
}
}
int ans = dp[k];
for(int& x : p){
ans += b[x];
}
cout << ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |