#include <bits/stdc++.h>
#define ll long long
#define pb push_back
using namespace std;
int n,m,k;
int a[555],b[555];
int dp[555][555];
int solve(int i,int k){
if(i==n)return 0;
int &ans=dp[i][k];
if(ans!=-1)return ans;
for(int j=0;j<=k&&j+a[i]<=m;j++){
ans=max(ans,b[a[i]+j]+solve(i+1,k-j));
}
return ans;
}
int main(){
cin>>n>>m>>k;
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<=m;i++){
cin>>b[i];
}
memset(dp,-1,sizeof dp);
cout<<solve(0,k);
return 0;
}
//ofstream fout("planting.out");
//ifstream fin("planting.in");
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1536 KB |
Output is correct |
2 |
Correct |
3 ms |
1536 KB |
Output is correct |
3 |
Correct |
191 ms |
1536 KB |
Output is correct |
4 |
Correct |
208 ms |
1656 KB |
Output is correct |
5 |
Correct |
234 ms |
1536 KB |
Output is correct |
6 |
Correct |
203 ms |
1508 KB |
Output is correct |
7 |
Correct |
219 ms |
1612 KB |
Output is correct |
8 |
Correct |
233 ms |
1656 KB |
Output is correct |
9 |
Correct |
193 ms |
1536 KB |
Output is correct |
10 |
Correct |
211 ms |
1536 KB |
Output is correct |