Submission #101974

# Submission time Handle Problem Language Result Execution time Memory
101974 2019-03-21T08:35:59 Z someone_aa Sličice (COCI19_slicice) C++17
18 / 90
6 ms 384 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 510;
ll dp[2][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];
    }

    for(int i=1;i<=n;i++) {

        int previ = (i-1) % 2;
        int curri = i % 2;

        for(int j=0;j<=k;j++) {
            // solve optimally for first i teams with k extra pictures
            int opt = 0;
            // if we can move opt to right move it
            while(opt + 1 <= j && dp[previ][opt] + b[p[i]+j-opt] <= dp[previ][opt+1] + b[p[i]+j-(opt+1)]) {
                opt++;
            }
            dp[curri][j] = dp[previ][opt] + b[p[i]+j-opt];
        }
    }
    cout<<dp[n%2][k]<<"\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Correct 3 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Incorrect 6 ms 384 KB Output isn't correct
5 Incorrect 6 ms 384 KB Output isn't correct
6 Incorrect 6 ms 384 KB Output isn't correct
7 Incorrect 5 ms 384 KB Output isn't correct
8 Incorrect 5 ms 384 KB Output isn't correct
9 Incorrect 6 ms 384 KB Output isn't correct
10 Incorrect 6 ms 384 KB Output isn't correct