# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
334942 | 2020-12-10T12:08:52 Z | ronnith | Sličice (COCI19_slicice) | C++14 | 70 ms | 1388 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 364 KB | Output is correct |
2 | Correct | 1 ms | 384 KB | Output is correct |
3 | Correct | 69 ms | 1388 KB | Output is correct |
4 | Correct | 68 ms | 1260 KB | Output is correct |
5 | Correct | 68 ms | 1388 KB | Output is correct |
6 | Correct | 67 ms | 1260 KB | Output is correct |
7 | Correct | 68 ms | 1260 KB | Output is correct |
8 | Correct | 70 ms | 1260 KB | Output is correct |
9 | Correct | 66 ms | 1260 KB | Output is correct |
10 | Correct | 70 ms | 1388 KB | Output is correct |