# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
100297 |
2019-03-10T09:55:53 Z |
mraron |
Sličice (COCI19_slicice) |
C++14 |
|
71 ms |
2680 KB |
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair
#ifndef ONLINE_JUDGE
# define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
# define LOG(x) ((void)0)
#endif
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const double PI=3.1415926535897932384626433832795;
const ll INF = 1LL<<62;
const ll MINF = -1LL<<62;
template<typename T> T getint() {
T val=0;
char c;
bool neg=false;
while((c=gc()) && !(c>='0' && c<='9')) {
neg|=c=='-';
}
do {
val=(val*10)+c-'0';
} while((c=gc()) && (c>='0' && c<='9'));
return val*(neg?-1:1);
}
int p[555];
ll b[555];
ll dp[555][555];
int main() {
IO;
int n,m,k;
cin>>n>>m>>k;
for(int i=0;i<n;++i) {
cin>>p[i];
}
for(int i=0;i<=m;++i) {
cin>>b[i];
}
for(int i=p[0];i<=m;++i) {
if(k-(i-p[0])<0) break ;
dp[0][k-(i-p[0])]=b[i];
}
for(int i=1;i<n;++i) {
for(int j=p[i];j<=m;++j) {
for(int l=0;l+(j-p[i])<=k;++l) {
dp[i][l]=max(dp[i][l], dp[i-1][l+(j-p[i])]+b[j]);
}
}
}
/*
for(int i=0;i<n;++i) {
for(int j=0;j<k;++j) cout<<dp[i][j]<<" ";cout<<"\n";
}*/
cout<<*max_element(dp[n-1], dp[n-1]+k+1)<<"\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
2304 KB |
Output is correct |
2 |
Correct |
5 ms |
2304 KB |
Output is correct |
3 |
Correct |
51 ms |
2680 KB |
Output is correct |
4 |
Correct |
66 ms |
2552 KB |
Output is correct |
5 |
Correct |
55 ms |
2524 KB |
Output is correct |
6 |
Correct |
49 ms |
2552 KB |
Output is correct |
7 |
Correct |
71 ms |
2552 KB |
Output is correct |
8 |
Correct |
53 ms |
2552 KB |
Output is correct |
9 |
Correct |
52 ms |
2552 KB |
Output is correct |
10 |
Correct |
50 ms |
2552 KB |
Output is correct |