# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125866 | OptxPrime | Sličice (COCI19_slicice) | C++11 | 73 ms | 1404 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 <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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |