QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#660581#5303. No Bug No GameLJY_ljyWA 3ms80156kbC++112.4kb2024-10-20 12:12:512024-10-20 12:12:52

Judging History

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

  • [2024-10-20 12:12:52]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:80156kb
  • [2024-10-20 12:12:51]
  • 提交

answer

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
using namespace std;

const long long MAXN = 3010;
const long long INF = 1e10;
long long n, k, p[MAXN], w[MAXN][MAXN];
long long maxw[11][MAXN], eid[11];
priority_queue<pair<long long, long long>> pq[11];
long long ans[11], maxx[11][11][MAXN], Ans;
long long maxx2[11][11][MAXN], sum[11][MAXN];

void dfs(long long N, long long K) {
	if (N == n + 1) {
		for (long long i = 1; i <= 10; i++) {
			if (ans[i] != 0 && K + i > k) {
				long long cnt = 0;
				for (long long u = 1; u <= 10; u++)
					cnt += sum[u][ans[u]];
				cnt += maxx[i][k - K][ans[i]];
				cnt += sum[i][ans[i] + 1] - sum[i][ans[i]];
				Ans = max(Ans, cnt);
				cnt = 0;
				for (long long u = 1; u <= 10; u++)
					cnt += sum[u][ans[u]];
				cnt += maxx2[i][k - K][ans[i] + 1];
				Ans = max(Ans, cnt);
			} 
		}
		long long cnt = 0;
		for (long long u = 1; u <= 10; u++)
			cnt += sum[u][ans[u]]; 
		Ans = max(Ans, cnt);
		return;
	}
	for (long long i = 0; i <= eid[N]; i++) {
		if (K + N * i <= k) {
			ans[N] = i;
			dfs(N + 1, K + N * i);
			ans[N] = 0;
		}	
	}
}

int main() {
	scanf("%lld %lld", &n, &k);
	for (long long i = 1; i <= n; i++) {
		scanf("%lld", &p[i]);
		for (long long j = 1; j <= p[i]; j++) {
			scanf("%lld", &w[i][j]);
		}
		pq[p[i]].push(make_pair(w[i][p[i]], i));
	}
	for (long long u = 1; u <= 10; u++) {
		while (!pq[u].empty()) {
			eid[u]++;
			maxw[u][eid[u]] = pq[u].top().second;
			pq[u].pop();
		}
	}
	for (long long u = 1; u <= 10; u++) {
		for (long long i = 1; i <= eid[u]; i++)
			sum[u][i] = sum[u][i - 1] + w[maxw[u][i]][u];
	}
	for (long long u = 1; u <= 10; u++) {
		for (long long y = 1; y < u; y++) {
			maxx[u][y][0] = -INF;
			for (long long i = 1; i <= eid[u]; i++)
				maxx[u][y][i] = max(maxx[u][y][i - 1], w[maxw[u][i]][y] - w[maxw[u][i]][u]);
		}
		for (long long y = 1; y < u; y++) {
			maxx2[u][eid[u] + 1][0] = -INF;
			for (long long i = eid[u]; i >= 1; i--)
				maxx2[u][y][i] = max(maxx[u][y][i + 1], w[maxw[u][i]][y]);
		}
	}
//	for (long long u = 1; u <= 10; u++) {
//		cout << u << endl;
//		for (long long y = 1; y < u; y++) {
//			for (long long i = 1; i <= eid[u]; i++)
//				cout << maxx[u][y][i] << " ";
//			cout << endl;
//			for (long long i = eid[u]; i >= 1; i--)
//				cout << maxx[u][y][i] << " ";
//			cout << endl;
//		}
//	}
	dfs(1, 0);
	printf("%lld\n", Ans);
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 10016kb

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: 3ms
memory: 80156kb

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:

0

result:

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