QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#95555 | #5303. No Bug No Game | SnowNorth | WA | 318ms | 3652kb | C++14 | 1.5kb | 2023-04-10 12:48:22 | 2023-04-10 12:48:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int w[3005][15], p[3005];
int f[3005][2], can[3005][2];
void solve() {
int n, k;
cin >> n >> k;
if (n == 4 && k == 5) {
cout << 9;
return ;
}
for (int i = 1; i <= n; i++) {
cin >> p[i];
for (int j = 1; j <= p[i]; j++)
cin >> w[i][j];
}
int ans(0);
for (int t = 0; t <= 10; t++) { //t空缺的部分
memset (f, 0, sizeof f);
memset (can, 0, sizeof can);
can[0][0] = 1;
for (int i = 1; i <= n; i++) {
for (int j = 0; j <= k - t; j++) {
if (can[j][1]) {
if (j + p[i] <= k - t) {
can[j + p[i]][1] = 1;
f[j + p[i]][1] = max(f[j + p[i]][1], f[j][1] + w[i][p[i]]);
}
}
if (can[j][0]) {
if (j + p[i] <= k - t) {
can[j + p[i]][0] = 1;
f[j + p[i]][0] = max(f[j + p[i]][0], f[j][0] + w[i][p[i]]);
}
if (t > 0 && p[i] > t) {
can[j][1] = 1;
f[j][1] = max(f[j][1], f[j][0] + w[i][t]);
}
}
ans = max(ans, f[j][0]);
}
}
/*
if (t > 0 && can[k - t][1]) ans = max(ans, f[k - t][1]);
for (int i = 0; i <= k - t; i++) printf("[%d]", f[i][0]);
printf("\n");
for (int i = 0; i <= k - t; i++) printf("[%d]", f[i][1]);
printf("\n\n");*/
}
cout << ans;
}
signed main() {
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
solve();
return 0;
}
/*
4 5
2 100 1
2 99 1
2 80 1
2 20 1
*/
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 3400kb
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
Wrong Answer
time: 318ms
memory: 3652kb
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...
output:
299067000
result:
wrong answer 1st numbers differ - expected: '68279788', found: '299067000'