Submission #103582

# Submission time Handle Problem Language Result Execution time Memory
103582 2019-03-31T18:15:11 Z kishtarn555 Sličice (COCI19_slicice) C++14
90 / 90
249 ms 2552 KB
#include<iostream>
#include<map>
#include<set>
#include<vector>

using namespace std;
int N,M, K;
long long b[505];
long long p[505];
long long memo[502][502];
long long dp (int cur, int K) {
    if (cur ==N)return 0;
    if (memo[cur][K])return memo[cur][K];
    memo[cur][K]=dp(cur+1,K)+b[p[cur]];
    for (int i = 0; i <= K && p[cur]+i<=M; i++) {
        memo[cur][K]=max(memo[cur][K],b[p[cur]+i]+dp(cur+1,K-i));
    }
    return memo[cur][K];
}
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >>N>>M>>K;
    for (int i =0; i < N; i++) {
        cin >> p[i];
    }
    for (int i =0; i <= M; i++) {
        cin >> b[i];
    }
    cout << dp(0,K);



    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 2304 KB Output is correct
2 Correct 4 ms 2304 KB Output is correct
3 Correct 141 ms 2296 KB Output is correct
4 Correct 168 ms 2504 KB Output is correct
5 Correct 157 ms 2396 KB Output is correct
6 Correct 160 ms 2424 KB Output is correct
7 Correct 144 ms 2552 KB Output is correct
8 Correct 158 ms 2316 KB Output is correct
9 Correct 153 ms 2360 KB Output is correct
10 Correct 249 ms 2424 KB Output is correct