#include <bits/stdc++.h>
#define pb push_back
#define int long long
using namespace std;
const int mod = 1e9 + 7;
const int inf = 1e17;
const int N = 2e5+5;
int32_t main(){
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
int n, m, k;
cin>>n>>m>>k;
vector<int> p(n), b(m+1);
for(int i = 0; i < n; i++){
cin>>p[i];
}
for(int i = 0; i <= m; i++){
cin>>b[i];
}
vector<vector<int> > dp(n+1, vector<int>(k+1, -inf));
dp[0][0] = 0;
for(int i = 0; i < n; i++){
for(int j = 0; j <= k; j++){
for(int pre = 0; pre <= j; pre++){
dp[i+1][j] = max(dp[i+1][j], dp[i][pre] + b[min(p[i] + (j - pre), m)]);
}
}
}
cout<<dp[n][k]<<endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
Output is correct |
2 |
Correct |
1 ms |
336 KB |
Output is correct |
3 |
Correct |
58 ms |
2384 KB |
Output is correct |
4 |
Correct |
57 ms |
2384 KB |
Output is correct |
5 |
Correct |
58 ms |
2384 KB |
Output is correct |
6 |
Correct |
64 ms |
2432 KB |
Output is correct |
7 |
Correct |
56 ms |
2384 KB |
Output is correct |
8 |
Correct |
57 ms |
2384 KB |
Output is correct |
9 |
Correct |
56 ms |
2388 KB |
Output is correct |
10 |
Correct |
59 ms |
2384 KB |
Output is correct |