QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#585874 | #5303. No Bug No Game | Nephrenn | TL | 1ms | 5728kb | C++20 | 1.6kb | 2024-09-23 22:36:22 | 2024-09-23 22:36:22 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
const i64 INF = 0x3f3f3f3f3f3f3f3f;
const int MAXN = 3010;
int n, k, p[MAXN];
i64 w[MAXN][20];
i64 dp[MAXN][MAXN][2];
i64 mx[MAXN][2];
void solve () {
cin >> n >> k;
for (int i = 1; i <= n; ++i) {
cin >> p[i];
for (int j = 1; j <= p[i]; ++j) {
cin >> w[i][j];
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= k; ++j) {
for (int k = 0; k <= j; ++k) {
// for (int l = 0; l <= i - 1; ++l) {
// if (k < p[i]) {
// dp[i][j][1] = max(dp[i][j][1], dp[l][j - k][0] + w[i][k]);
// } else {
// dp[i][j][0] = max(dp[i][j][0], dp[l][j - k][0] + w[i][k]);
// dp[i][j][1] = max(dp[i][j][1], dp[l][j - k][1] + w[i][k]);
// }
// }
if (k < p[i]) {
dp[i][j][1] = max(dp[i][j][1], mx[j - k][0] + w[i][k]);
} else {
dp[i][j][0] = max(dp[i][j][0], mx[j - k][0] + w[i][k]);
dp[i][j][1] = max(dp[i][j][1], mx[j - k][1] + w[i][k]);
}
mx[j][0] = max(mx[j][0], dp[i][j][0]);
mx[j][1] = max(mx[j][1], dp[i][j][1]);
}
}
}
cout << max(dp[n][k][0], dp[n][k][1]) << "\n";
}
int main () {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1;
// cin >> t;
while (t--) {
solve ();
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 5728kb
input:
4 5 2 1 3 2 1 1 2 3 1 2 1 3
output:
9
result:
ok 1 number(s): "9"
Test #2:
score: -100
Time Limit Exceeded
input:
3000 3000 10 70562 30723 79371 82224 63977 3362 26909 96449 48163 66159 4 18007 33590 80674 91139 4 10304 31694 70745 50656 10 63090 17226 13187 73881 38137 15237 55750 82751 75854 39658 8 95640 66120 87735 36388 44046 92415 6952 94772 9 60565 27904 98726 87052 35768 25453 14563 34273 92501 10 66332...