Submission #226896

#TimeUsernameProblemLanguageResultExecution timeMemory
226896DavidDamianSličice (COCI19_slicice)C++11
90 / 90
101 ms1400 KiB
#include <bits/stdc++.h> using namespace std; ///Dynamic Programming ///Determine the maximum number of points when adding some extra images int memo[505][505]; int A[505]; int B[1005]; int sum[505]; int n,m,K; int main() { ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin>>n>>m>>K; for(int i=1;i<=n;i++){ cin>>A[i]; } for(int i=0;i<=m;i++){ cin>>B[i]; } for(int i=1;i<=n;i++){ sum[i]=sum[i-1]+B[ A[i] ]; } for(int i=m+1;i<=2*m+1;i++){ B[i]=B[i-1]; } for(int i=1;i<=n;i++){ memo[i][0]=sum[i]; for(int k=1;k<=K;k++){ for(int j=0;j<=k;j++){ memo[i][k]=max(memo[i][k],memo[i-1][k-j] +B[ A[i]+j ]); } } } cout<<memo[n][K]<<'\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...