Submission #101977

# Submission time Handle Problem Language Result Execution time Memory
101977 2019-03-21T08:47:07 Z someone_aa Sličice (COCI19_slicice) C++17
0 / 90
9 ms 1280 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 55;
ll dp[maxn][maxn*maxn];
ll n, m, k;

ll p[maxn], b[maxn];

int main() {
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++) {
        cin>>p[i];
    }

    for(int i=0;i<=m;i++) {
        cin>>b[i];
    }

    // dp[i][k] -> prefix of size i with k more pictures

    ll result = 0LL;
    for(int i=1;i<=n;i++) {
        for(int j=0;j<=k;j++) {
            dp[i][j] = dp[i-1][j] + b[p[i]];
            for(int c=0;c+p[i]<=m;c++) {
                if(j - c >= 0)
                    dp[i][j] = max(dp[i][j], dp[i-1][j-c] + b[c+p[i]]);
            }
            result = max(result, dp[i][j]);
        }
    }
    cout<<result<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 7 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Runtime error 4 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
3 Runtime error 4 ms 1024 KB Execution killed with signal 11 (could be triggered by violating memory limits)
4 Runtime error 5 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
5 Runtime error 6 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
6 Runtime error 4 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
7 Runtime error 6 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)
8 Runtime error 3 ms 896 KB Execution killed with signal 11 (could be triggered by violating memory limits)
9 Runtime error 4 ms 1152 KB Execution killed with signal 11 (could be triggered by violating memory limits)
10 Runtime error 9 ms 1280 KB Execution killed with signal 11 (could be triggered by violating memory limits)