QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#739708 | #5303. No Bug No Game | ZHYa | WA | 203ms | 74360kb | C++23 | 1.7kb | 2024-11-12 22:45:24 | 2024-11-12 22:45:27 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
void solve()
{
int n, k;
cin >> n >> k;
vector<vector<int>> res(n + 1);
for (int i = 1; i <= n; i++)
{
int p;
cin >> p;
res[i].push_back(p);
for (int j = 1; j <= p; j++)
{
int x;
cin >> x;
res[i].push_back(x);
}
}
int ans = 0;
for (int p = 1; p <= 10; p++)
{
vector<vector<array<int, 2>>> dp(n + 10, vector<array<int, 2>>(k + 10, {INT_MIN, INT_MIN}));
dp[0][0][0] = 0;
for (int i = 1; i <= n; i++)
{
int vmax = res[i][0];
for (int j = k; j >= vmax; j--)
{
dp[i][j][0] = max(dp[i - 1][j][0], dp[i - 1][j - vmax][0] + res[i][vmax]);
if (dp[i][j][0] < 0)
dp[i][j][0] = INT_MIN;
dp[i][j][1] = max(dp[i - 1][j][1], dp[i - 1][j - vmax][1] + res[i][vmax]);
if (dp[i][j][1] < 0)
dp[i][j][1] = INT_MIN;
}
if (p <= vmax)
{
for (int j = k; j >= p; j--)
{
dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j - p][0] + res[i][p]);
if (dp[i][j][1] < 0)
dp[i][j][1] = INT_MIN;
}
}
}
if (dp[n][k][0] > 0)
ans = max(ans, dp[n][k][0]);
if (dp[n][k][1] > 0)
ans = max(ans, dp[n][k][1]);
}
cout << ans << endl;
}
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin>>t;
while (t--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3656kb
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: 203ms
memory: 74360kb
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:
68233938
result:
wrong answer 1st numbers differ - expected: '68279788', found: '68233938'