QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#58703#4412. Boss Rushqinjianbin#WA 1470ms17704kbC++171.8kb2022-10-27 13:52:282022-10-27 13:52:30

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-10-27 13:52:30]
  • 评测
  • 测评结果:WA
  • 用时:1470ms
  • 内存:17704kb
  • [2022-10-27 13:52:28]
  • 提交

answer

#include<iostream>
using namespace std;
#define ll long long


const int MAXN = 3e5 + 10, MAXM = 1e5 + 10;
ll dp[MAXN];


int T, n, edsta;
int t[20], tim[MAXN];
ll len[20][MAXM];
ll H;

void init() {
	for (int i = 0; i <= edsta; i++) {
		for (int j = 1; j <= n; j++) {
			if ((i >> (j - 1)) & 1) {
				tim[i] += t[j];
			}
		}
		// tim[i] -= 1;
	}
}

bool Check(int mid) {
	ll MAX = 0;
	for (int i = 0; i <= edsta; i++) 
		dp[i] = 0;
	for (int i = 0; i <= edsta; i++) {
		if (tim[i] > mid) continue;
		for (int j = 1; j <= n; j++) {
			if ((i >> (j - 1)) & 1) continue;
			int nx = i | (1 << (j - 1));
			int r = min(len[j][0], (ll)mid - tim[i] + 1);
			dp[nx] = max(dp[nx], dp[i] + len[j][r]);
			MAX = max(MAX, dp[nx]);
			// if ((i >> (j - 1)) & 1) {
			// 	int lst = i ^ (1 << (j - 1));
			// 	// printf("asd%d %d\n", tim[lst], mid);
			// 	if (tim[lst] >= mid) continue;
			// 	int r = min((ll)mid - tim[lst], len[j][0]); //time
			// 	// printf("%d %lld\n", j, len[j][r]);
			// 	dp[i] = max(dp[lst] + len[j][r], dp[i]);
				// printf("%d %lld\n", nx, dp[nx]);
			// 	MAX = max(MAX, dp[i]);
			// }
		}
	}
	// printf("%lld %d", MAX, mid);
	return MAX >= H ? 0 : 1;
}

int main() {
	scanf("%d", &T);
	while (T--) {
		scanf("%d%lld", &n, &H);
		edsta = (1 << n) - 1;
		for (int i = 1; i <= n; i++) {
			scanf("%d%lld", &t[i], &len[i][0]);
			for (int j = 1; j <= len[i][0]; j++) 
				scanf("%lld", &len[i][j]);
			for (int j = 2; j <= len[i][0]; j++) 
				len[i][j] += len[i][j - 1];
		}
		init();
		int l = 0, r = 2e6 + 10;
		while (l < r) {
			int mid = l + r >> 1;
			if (Check(mid)) l = mid + 1;
			else r = mid;
			// printf("%d %d\n", l, r);
		}
		if (l == 2e6 + 10) l = -1;
		printf("%d\n", l);
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1470ms
memory: 17704kb

input:

100
10 293367178351
89 52
117480172 951737726 356435682 180765874 775623083 281703307 290364363 366421773 989361116 796791408 389709469 534380525 412173405 463001602 578985383 272777986 833157533 444367936 841474617 472532665 952319800 583679381 924952511 892974994 105808118 171375863 320943603 4870...

output:

368
1122
1773
884
2134
1825
1983
5326
3235
5870
5613
6195
6607
8142
5352
10515
6071
7856
8348
5753
5916
9113
9337
8022
9882
12061
3408
7103
16621
9423
7656
10158
14482
17051
17375
10831
8968
11346
13519
7083
19159
9581
9804
9877
15458
12963
13183
16247
10832
17571
26560
15217
27417
21388
25052
28743...

result:

wrong answer 2nd lines differ - expected: '579', found: '1122'