QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#593235#5303. No Bug No GameIron_gainerWA 53ms73872kbC++201.5kb2024-09-27 12:49:472024-09-27 12:49:47

Judging History

你现在查看的是最新测评结果

  • [2024-09-27 12:49:47]
  • 评测
  • 测评结果:WA
  • 用时:53ms
  • 内存:73872kb
  • [2024-09-27 12:49:47]
  • 提交

answer

#include<iostream>
#include<vector>
#include<array>
#include<random>
#include<queue>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int, int> pii;
constexpr int inf = 1e9;
void solve()
{
	int n, k;
	cin >> n >> k;
	vector<vector<array<int, 2>>>dp(n + 1, vector<array<int, 2>>(k + 1, { -inf, -inf}));
	vector<array<int, 11>>v(n + 1);
	for (int i = 1; i <= n; i++)
	{
		cin >> v[i][0];
		for (int j = 1; j <= v[i][0]; j++)
		{
			cin >> v[i][j];
		}
	}
	dp[0][0][0] = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 0; j <= k; j++)
		{
			dp[i][j][0] = dp[i - 1][j][0];
			if (j >= v[i][0])
			{
				dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j - v[i][0]][0] + v[i][v[i][0]]);
				dp[i][j][1] = max(dp[i - 1][j - v[i][0]][1] + v[i][v[i][0]], dp[i][j][1]);
			}
			for (int k = 1; k < v[i][0] && j >= k; k++)
			{
				dp[i][j][1] = max(dp[i - 1][j - k][0] + v[i][k], dp[i][j][1]);
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		for (int j = 1; j <= k; j++)
		{
			ans = max(ans, dp[i][j][0]);
		}
		ans = max(ans, dp[i][k][1]);
	}
	cout << ans << endl;
}
void speed()
{
	ios::sync_with_stdio(0);
	cin.tie(0);                                                                                          
	cout.tie(0);
}
int main()
{
	speed();
	int t;
	//cin >> t;
	t = 1;
	while (t--)
	{
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3652kb

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: 53ms
memory: 73872kb

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:

68245988

result:

wrong answer 1st numbers differ - expected: '68279788', found: '68245988'