# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
318658 |
2020-11-02T20:11:05 Z |
neki |
Sličice (COCI19_slicice) |
C++14 |
|
131 ms |
504 KB |
#include <bits/stdc++.h>
#define loop(i, a, b) for(long long i=a;i<b;i++)
#define pool(i, a, b) for(long long i=a-1;i>=b;i--)
#define fore(i, a) for(auto&& i:a)
#define fi first
#define se second
#define ps(a) push_back(a)
#define pb(a) pop_back(a)
#define sc scanf
#define vc vector
#define pa pair<ll, ll>
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(), a.end()
#define llmax LLONG_MAX/2
#define llmin -LLONG_MAX/2
using namespace std;
#define mn 510
#define pa pair<ll, ll>
#define ld long double
ll arr[mn], rew[mn];
int main(){
ll n, m, k;cin >> n>>m>>k;
loop(i, 0, n) cin >> arr[i];
loop(i, 0, m+1) cin >> rew[i];
vc<ll> dp(k+1, 0);
loop(i, 0, n){
vc<ll> ndp(k+1, 0);
vc<ll> neki(k+1, 0);
loop(j, arr[i]+1, m+1) neki[j-arr[i]]=rew[j] - rew[arr[i]];
loop(x, 0, k+1){
loop(y, 0, k+1) if(x+y<=k) ndp[x+y]=max(ndp[x+y], dp[x]+neki[y]);
}
dp=ndp;
}
ll ans=0;
loop(i, 0, k+1) ans=max(ans, dp[i]);
loop(i, 0, n) ans+=rew[arr[i]];
cout << ans <<endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
2 |
Runtime error |
1 ms |
492 KB |
Execution killed with signal 6 (could be triggered by violating memory limits) |
3 |
Correct |
126 ms |
364 KB |
Output is correct |
4 |
Correct |
127 ms |
364 KB |
Output is correct |
5 |
Correct |
126 ms |
364 KB |
Output is correct |
6 |
Correct |
128 ms |
484 KB |
Output is correct |
7 |
Correct |
126 ms |
364 KB |
Output is correct |
8 |
Correct |
130 ms |
364 KB |
Output is correct |
9 |
Correct |
131 ms |
364 KB |
Output is correct |
10 |
Correct |
129 ms |
504 KB |
Output is correct |