# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
100267 | ami | Sličice (COCI19_slicice) | C++14 | 53 ms | 1528 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 sz(c) int(c.size())
#define rep(i,a,b) for (int i=a; i<(b); ++i)
#define per(i,a,b) for (int i=(b)-1; i>=(a); --i)
using namespace std;
using ll = long long;
int const INF=1e9;
int const MAXN=550;
int N,M,K;
int P[MAXN];
int B[MAXN];
int f[MAXN][MAXN];
int main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
cout<<fixed<<setprecision(10);
cin>>N>>M>>K;
rep(i,0,N) cin>>P[i];
rep(i,0,M+1) cin>>B[i];
rep(i,0,N+1) rep(j,0,K+1) f[i][j]=-INF;
f[0][0]=0;
rep(i,0,N) rep(j,0,K+1) rep(k,0,min(M-P[i]+1,K-j+1)) {
f[i+1][j+k]=max(f[i+1][j+k],f[i][j]+B[P[i]+k]);
}
cout<<f[N][K]<<"\n";
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |