Submission #570669

#TimeUsernameProblemLanguageResultExecution timeMemory
570669AGESličice (COCI19_slicice)C++14
90 / 90
62 ms2276 KiB
#include<bits/stdc++.h> #define F first #define S second #define pb push_back #define int long long using namespace std; int dp[505][505],a[505],b[505]; main() { int n,m,kk; cin>>n>>m>>kk; for(int i=0;i<=500;i++) for(int j=0;j<=500;j++) dp[i][j]=-1e18; for(int i=0;i<n;i++) cin>>a[i]; for(int i=0;i<=m;i++) cin>>b[i]; dp[0][kk]=b[a[0]]; for(int i=a[0];i<=m;i++){ if(kk-(i-a[0])<0) continue; dp[0][kk-(i-a[0])]=max(dp[0][kk-(i-a[0])],b[i]); } for(int i=0;i<n;i++){ for(int j=0;j<=kk;j++){ for(int k=a[i+1];k<=m;k++){ int x=j-(k-a[i+1]); if(x<0) continue; dp[i+1][x]=max(dp[i+1][x],dp[i][j]+b[k]); } } } int ans=-1e18; for(int i=0;i<=kk;i++) ans=max(ans,dp[n-1][i]); cout<<ans<<endl; return 0; }

Compilation message (stderr)

slicice.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...