# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
541442 | ala2 | Sličice (COCI19_slicice) | C++14 | 261 ms | 2340 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 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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |