Submission #541442

#TimeUsernameProblemLanguageResultExecution timeMemory
541442ala2Sličice (COCI19_slicice)C++14
90 / 90
261 ms2340 KiB
#include <bits/stdc++.h> #define int long long #define F first #define S second #define pb push_back #define B begin() #define E end() using namespace std; int n,m; int a[1001000]; int b[1001000]; int dp[505][505]; int f(int i,int k) { if(i==n) return 0; int mx=0; if(dp[i][k]+1) return dp[i][k]; for(int j=0;j<=k;j++) { mx=max(mx , b[a[i]+j]+f(i+1,k-j) ); //cout<<" "<<i<<" "<<j<<" "<<k<<" "<<mx<<endl; } return dp[i][k]=mx; } signed main() { memset(dp,-1,sizeof dp); int k; cin>>n>>m>>k; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<m+1;i++) cin>>b[i]; cout<<""<<f(0,k)<<endl; }
#Verdict Execution timeMemoryGrader output
Fetching results...