QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#276115 | #5303. No Bug No Game | ucup-team059# | WA | 0ms | 3436kb | C++20 | 939b | 2023-12-05 16:36:47 | 2023-12-05 16:36:49 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
using i32 = int32_t;
using vi = vector<int>;
const int inf = 1e18;
i32 main() {
ios::sync_with_stdio(false), cin.tie(nullptr);
int n, m, sum = 0;
cin >> n >> m;
vector f(m + 1, vi(2, -inf));
f[0][0] = 0;
for (int i = 1, p; i <= n; i++) {
cin >> p, sum = min(sum + p, m);
vi w(p + 1);
for (int j = 1; j <= p; j++) cin >> w[j];
for (int j = m; j >= 0; j--) {
if (j - p >= 0) {
if (f[j - p][0] > -inf) f[j][0] = max(f[j][0], f[j - p][0] + w[p]);
if (f[j - p][0] > -inf) f[j][1] = max(f[j][1], f[j - p][1] + w[p]);
}
for (int k = 1; k <= p; k++)
if (j - k >= 0 and f[j - k][0] > -inf) f[j][1] = max(f[j][1], f[j - k][0] + w[k]);
}
}
cout << max( f[sum][0] , f[sum][1] );
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3436kb
input:
4 5 2 1 3 2 1 1 2 3 1 2 1 3
output:
7
result:
wrong answer 1st numbers differ - expected: '9', found: '7'