Submission #125866

#TimeUsernameProblemLanguageResultExecution timeMemory
125866OptxPrimeSličice (COCI19_slicice)C++11
90 / 90
73 ms1404 KiB
#include <iostream> #include <cmath> #include<vector> #include <algorithm> #include <utility> #include<stack> #include<queue> #include<map> #include <fstream> using namespace std; #define pb push_back #define mp make_pair #define ll long long int n,m,k; int a[510]; int b[510]; int dp[510][510]; int val[510]; int main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cin>>n>>m>>k; for( int i=1;i<=n;i++ ){ cin>>a[i]; } for( int i=0;i<=m;i++ ) cin>>val[i]; for( int i=0;i<=m;i++ ) dp[0][i] = 0; for( int i=1;i<=n;i++ ){ for( int j=0;j<=k;j++ ){ for( int p=0;p<=j;p++ ){ // if( j-p < 0 ) break; dp[i][j] = max( dp[i][j], dp[i-1][j-p] + val[ a[i] + p ] ); } } } cout <<dp[n][k]<<endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...