Submission #101201

#TimeUsernameProblemLanguageResultExecution timeMemory
101201mayhoubsalehSličice (COCI19_slicice)C++14
90 / 90
234 ms1656 KiB
#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 timeMemoryGrader output
Fetching results...