QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#716907 | #5303. No Bug No Game | wangshengzhe | WA | 0ms | 3684kb | C++14 | 1.3kb | 2024-11-06 16:19:53 | 2024-11-06 16:19:53 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<unordered_map>
#include<stack>
using namespace std;
#define int long long
#define scanf scanf_s
typedef pair<int, int> PII;
const double ef = 1e-12;
const int INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1e9 + 7;
#define rep(i,a, b) for(int i = a;i<=b;i++)
#define pre(i,a, b) for(int i = a;i>=b;i--)
int n, v;
int num[3005];
int p[3005][15];
int dp[3005][2];
signed main()
{
cin >> n >> v;
rep(i, 1, n)
{
cin >> num[i];
rep(j, 1, num[i]) cin >> p[i][j];
}
memset(dp, -0x3f, sizeof dp);
dp[0][0] = 0;
rep(i, 1, n)
{
pre(k, v, 0)
{
if (k >= num[i])
{
dp[k][0] = max(dp[k][0], dp[k - num[i]][0] + p[i][num[i]]);
dp[k][1] = max(dp[k][1], dp[k - num[i]][1] + p[i][num[i]]);
}
rep(j, 1, num[i]) {
if (k >= j) dp[k][1] = max(dp[k][1], dp[k - j][0] + p[i][j]);
}
}
}
int ans = 0;
rep(i, 1, n)
rep(k, 0, v)
ans = max(ans, dp[i][k]);
cout << ans << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3684kb
input:
4 5 2 1 3 2 1 1 2 3 1 2 1 3
output:
6
result:
wrong answer 1st numbers differ - expected: '9', found: '6'