/*input
3 6 2
2 4 1
31 38 48 60 75 91 120
*/
#include <bits/stdc++.h>
#define fastIo ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define sz size
#define pb push_back
#define mp make_pair
using namespace std;
//#define LOCAL
#ifdef LOCAL
#define DEBUG(x) do { cout << #x << ": " << x << '\n'; } while (0)
#else
#define DEBUG(x)
#endif
const double EPS = 1e-9;
const double PI = 3.141592653589793238462;
const int dr[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dc[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
int p[505], b[505], dp[505][505];
int main(){
fastIo;
int n, m, k;
cin >> n >> m >> k;
for(int i = 1; i <= n; i++){
cin >> p[i];
}
for(int i = 0; i <= m; i++){
cin >> b[i];
}
for(int i = 1; i <= n; i++){
dp[i][0] = b[p[i]];
for(int j = 1; j <= k; j++){
for(int t = 0; t <= j; t++){
if(j - t + p[i] > m) continue;
dp[i][j] = max(dp[i][j], dp[i - 1][t] + b[p[i] + j - t]);
}
}
}
int ans = 0;
for(int i = 0; i <= k; i++){
ans = max(ans, dp[n][i]);
}
cout << ans << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
1280 KB |
Output isn't correct |
2 |
Incorrect |
3 ms |
1408 KB |
Output isn't correct |
3 |
Correct |
130 ms |
1372 KB |
Output is correct |
4 |
Correct |
128 ms |
1348 KB |
Output is correct |
5 |
Correct |
128 ms |
1400 KB |
Output is correct |
6 |
Correct |
128 ms |
1400 KB |
Output is correct |
7 |
Correct |
127 ms |
1380 KB |
Output is correct |
8 |
Incorrect |
136 ms |
1424 KB |
Output isn't correct |
9 |
Correct |
118 ms |
1424 KB |
Output is correct |
10 |
Correct |
128 ms |
1344 KB |
Output is correct |