# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334942 | ronnith | Sličice (COCI19_slicice) | C++14 | 70 ms | 1388 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 trav(a, b) for(auto a : b)
#define mk make_pair
#define f first
#define s second
#define vi vector<int>
#define pb push_back
using namespace std;
int main(){
// ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int n, m, k;
scanf("%d%d%d", &n, &m, &k);
int p[n], b[m + 1];
for(int i = 0;i < n;i ++)scanf("%d", &p[i]);
for(int i = 0;i < m + 1;i ++)scanf("%d", &b[i]);
int dp[n][k + 1];
for(int i = 0;i < n;i ++){
for(int j = 0;j <= k;j ++){
dp[i][j] = 0;
if(i == 0){
int nw = min(j + p[i], m);
dp[i][j] = b[nw];
} else {
for(int K = p[i];K - p[i] <= j and K <= m;K ++){
dp[i][j] = max(dp[i][j], b[K] + dp[i - 1][j - (K - p[i])]);
}
}
}
}
printf("%d\n", dp[n - 1][k]);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |