# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
541442 |
2022-03-23T15:26:06 Z |
ala2 |
Sličice (COCI19_slicice) |
C++14 |
|
261 ms |
2340 KB |
#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 |
1 |
Correct |
1 ms |
2260 KB |
Output is correct |
2 |
Correct |
2 ms |
2308 KB |
Output is correct |
3 |
Correct |
251 ms |
2332 KB |
Output is correct |
4 |
Correct |
253 ms |
2328 KB |
Output is correct |
5 |
Correct |
255 ms |
2340 KB |
Output is correct |
6 |
Correct |
257 ms |
2340 KB |
Output is correct |
7 |
Correct |
243 ms |
2332 KB |
Output is correct |
8 |
Correct |
250 ms |
2260 KB |
Output is correct |
9 |
Correct |
254 ms |
2260 KB |
Output is correct |
10 |
Correct |
261 ms |
2332 KB |
Output is correct |