// =================================
// author: memset0
// date: 2019.07.16 08:30:00
// website: https://memset0.cn/
// =================================
#include <bits/stdc++.h>
#define ll long long
#define rep(i, l, r) for (int i = (l), i##ed = (r); i <= i##ed; ++i)
#define for_each(i, a) for (size_t i = 0, i##ed = a.size(); i < i##ed; ++i)
namespace ringo {
template <class T> inline void read(T &x) {
x = 0; char c = getchar(); bool f = 0;
while (!isdigit(c)) f ^= c == '-', c = getchar();
while (isdigit(c)) x = x * 10 + c - '0', c = getchar();
if (f) x = -x;
}
template <class T> inline void print(T x) {
if (x < 0) putchar('-'), x = -x;
if (x > 9) print(x / 10);
putchar('0' + x % 10);
}
template <class T> inline void print(T x, char c) { print(x), putchar(c); }
template <class T> inline void print(T a, int l, int r, std::string s = "") {
if (s != "") std::cout << s << ": ";
for (int i = l; i <= r; i++) print(a[i], " \n"[i == r]);
}
const int N = 2e5 + 10, M = 32;
ll f[M][M][M][M];
int T, n, m, p, a[N], b[N];
void gaygay() {
}
void main() {
read(n), read(m), read(p), m -= p;
if (n > 30) return gaygay();
for (int i = 1; i <= n; i++) read(a[i]);
for (int i = 1; i <= n; i++) read(b[i]);
f[0][0][0][0] = 0;
// printf("%d %d %d\n", n, m, p);
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= i && j <= m; j++)
for (int k = 0; k <= i && k <= m; k++)
for (int l = 0; l <= i && l <= p; l++) {
// printf("> %d %d %d %d\n", i, j, k, l);
f[i][j][k][l] = f[i - 1][j][k][l];
if (j) f[i][j][k][l] = std::max(f[i][j][k][l], f[i - 1][j - 1][k][l] + a[i]);
if (k) f[i][j][k][l] = std::max(f[i][j][k][l], f[i - 1][j][k - 1][l] + b[i]);
if (l) f[i][j][k][l] = std::max(f[i][j][k][l], f[i - 1][j][k][l - 1] + a[i] + b[i]);
if (j && k) f[i][j][k][l] = std::max(f[i][j][k][l], f[i - 1][j - 1][k - 1][l] + a[i] + b[i]);
}
}
print(f[n][m][m][p], '\n');
}
} signed main() {
#ifdef memset0
freopen("sequence2.in", "r", stdin);
#else
freopen("sequence.in", "r", stdin);
freopen("sequence.out", "w", stdout);
#endif
ringo::read(ringo::T);
while (ringo::T--) {
ringo::main();
}
return 0;
}
| Compilation | N/A | N/A | Compile OK | Score: N/A | 显示更多 |
| Testcase #1 | 57.41 us | 252 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #2 | 86.78 us | 348 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #3 | 90.99 us | 404 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #4 | 174.9 us | 972 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #5 | 275.73 us | 1 MB + 100 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #6 | 565.12 us | 1 MB + 644 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #7 | 1.289 ms | 2 MB + 732 KB | Accepted | Score: 4 | 显示更多 |
| Testcase #8 | 35.73 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #9 | 35.14 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #10 | 35.24 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #11 | 33.97 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #12 | 34.75 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #13 | 34.54 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #14 | 34.57 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #15 | 33.97 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #16 | 35.09 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #17 | 33.86 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #18 | 34.2 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #19 | 33.72 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #20 | 34.15 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #21 | 34.47 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #22 | 34.7 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #23 | 34.29 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #24 | 35.05 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |
| Testcase #25 | 34.09 us | 44 KB | Wrong Answer | Score: 0 | 显示更多 |