Submission #100267

#TimeUsernameProblemLanguageResultExecution timeMemory
100267amiSličice (COCI19_slicice)C++14
90 / 90
53 ms1528 KiB
#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 timeMemoryGrader output
Fetching results...