QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#722108#5303. No Bug No GameSmHaInTWA 100ms145464kbC++202.3kb2024-11-07 17:51:092024-11-07 17:51:13

Judging History

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

  • [2024-11-07 17:51:13]
  • 评测
  • 测评结果:WA
  • 用时:100ms
  • 内存:145464kb
  • [2024-11-07 17:51:09]
  • 提交

answer

#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<string.h>
#include <string>
#include<math.h>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<map>
#include<queue>
#include<stack>
#include<functional>
#include<deque>
using namespace std;

const int MAXN = 3010;
#define int long long
#define ll long long
#define lll unsigned long long
#define PA pair<ll,ll>
#define INF (ll)0x3f3f3f3f*(ll)1000000
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const ll mod = 1e9 + 7;

int dp[MAXN][MAXN][2];
vector<vector<int>>p;

void solve() {
	int ans = 0;
	int n, m; cin >> n >> m;
	p.resize(n + 1, vector<int>(1));
	for (int i = 1; i <= n; i++) {
		int k; cin >> k;
		for (int j = 0; j < k; j++) {
			int num; cin >> num;
			p[i].push_back(num);
		}
	}
	
	for (int i = 0; i < MAXN; i++) {
		for (int j = 0; j < MAXN; j++) {
			for (int k = 0; k < 2; k++) {
				dp[i][j][k] = -INF;
			}
		}
	}
	for (int i = 0; i <= n; i++)dp[i][m][0] = 0;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < p[i].size() - 1; j++) {

			for (int w = m; w >= 0; w--) {
				dp[i][w][1] = max(dp[i][w][1], dp[i - 1][w][1]);
			}

			for (int w = m; w >= 0; w--) {
				//dp[i][w][1] = max(dp[i][w][1], dp[i - 1][w][1]);
				if (w - j >= 0){
					//dp[i][w - j][1] = max(dp[i][w - j][1], dp[i - 1][w - j][1]);
					dp[i][w - j][1] = max(dp[i][w - j][1], dp[i - 1][w][0] + p[i][j]);
					//ans = max(ans, dp[i][w - j][1]);
				}

			}
		}
		int j = p[i].size() - 1;

		for (int w = m; w >= 0; w--) {
			dp[i][w][0] = max(dp[i][w][0], dp[i - 1][w][0]);
		}

		for (int w = m; w >= 0; w--) {
			//dp[i][w][0] = max(dp[i][w][0], dp[i - 1][w][0]);
			if (w - j >= 0) {
				dp[i][w - j][0] = max(dp[i][w - j][0], dp[i - 1][w][0] + p[i][j]);
				dp[i][w - j][1] = max(dp[i][w - j][1], dp[i - 1][w][1] + p[i][j]);
				//ans = max({ ans, dp[i][w - j][0], dp[i][w - j][1] });
			}
		}
	}

	for (int i = 1; i <= n; i++) {
		for (int j = m; j >= 0; j--) {
			ans = max(ans, dp[i][j][0]);
		}
	}
	for (int i = 1; i <= n; i++) {
		ans = max(ans, dp[i][0][1]);
	}
	
	cout << ans << endl;
}


signed main() {
	IOS;
	int t = 1; //cin >> t;
	while (t--) {
		solve();
	}
}

详细

Test #1:

score: 100
Accepted
time: 3ms
memory: 145096kb

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: 100ms
memory: 145464kb

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:

68270067

result:

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