QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#693141 | #5303. No Bug No Game | the_fool# | WA | 133ms | 144528kb | C++20 | 1.9kb | 2024-10-31 15:36:37 | 2024-10-31 15:36:45 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int LL
using LL = long long;
using ll = long long;
constexpr int N = 3010;
constexpr LL inf = 1E18;
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n, k;
cin >> n >> k;
vector<vector<int>> w(n + 1);
vector<int> p(n + 1);
for (int i = 1; i <= n; i++) {
cin >> p[i];
w[i].resize(p[i] + 1);
for (int j = 1; j <= p[i]; j++) {
cin >> w[i][j];
}
}
vector<array<LL, N>> pre(n + 1);
for (int i = 0; i <= n; i++) {
fill(pre[i].begin() + 1, pre[i].end(), -inf);
pre[i][0] = 0;
}
for (int i = 1; i <= n; i++) {
for (int j = p[i]; j < N; j++) {
pre[i][j] = max(pre[i - 1][j], pre[i - 1][j - p[i]] + w[i].back());
}
}
// for (int i = 1; i <= n; i++) {
// for (int j = 0; j <= 10; j++) {
// cout << pre[i][j] << " ";
// }
// cout << "\n";
// }
vector<array<LL, N>> suf(n + 2, array<LL, N>{});
for (int i = 0; i <= n + 1; i++) {
fill(suf[i].begin() + 1, suf[i].end(), -inf);
suf[i][0] = 0;
}
for (int i = n; i >= 1; i--) {
for (int j = p[i]; j < N; j++) {
suf[i][j] = max(suf[i + 1][j], suf[i + 1][j - p[i]] + w[i].back());
}
}
LL ans = 0;
for (int i = 1; i < N; i++) {
ans = max(ans, pre[n][i]);
}
for (int i = 1; i <= n; i++) {
LL dp[11] = {};
for (int s = 0; s <= 10; s++) {
for (int j = 0; j <= k; j++) {
if (k - s - j < 0) continue;
dp[s] = max(dp[s], pre[i - 1][j] + suf[i + 1][k - s - j]);
}
}
for (int j = 1; j < p[i]; j++) {
ans = max(ans, dp[j] + w[i][j]);
}
}
cout << ans << "\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3912kb
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: 133ms
memory: 144528kb
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:
68245968
result:
wrong answer 1st numbers differ - expected: '68279788', found: '68245968'