# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
101201 | mayhoubsaleh | Sličice (COCI19_slicice) | C++14 | 234 ms | 1656 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 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 |
---|---|---|---|---|
Fetching results... |