QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#58691#4412. Boss Rushqinjianbin#WA 2149ms17056kbC++171.5kb2022-10-27 13:15:172022-10-27 13:15:20

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:15:20]
  • 评测
  • 测评结果:WA
  • 用时:2149ms
  • 内存:17056kb
  • [2022-10-27 13:15:17]
  • 提交

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() {
	tim[0] = -1;
	for (int i = 1; i <= edsta; i++) 
		for (int j = 1; j <= n; j++) {
			if ((i >> (j - 1)) & 1) {
				tim[i] += t[j];
			}
		}
}

bool Check(int mid) {
	ll MAX = 0;
	for (int i = 0; i <= edsta; i++) 
		dp[i] = 0;
	for (int i = 1; i <= edsta; i++) {
		for (int j = 1; j <= n; j++) {
			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", i, dp[i]);
				MAX = max(MAX, dp[i]);
			}
		}
	}
	// printf("%lld\n", MAX);
	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;
		}
		if (l == 2e6 + 10) l = -1;
		printf("%d\n", l);
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 2149ms
memory: 17056kb

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:

369
1123
1774
885
2135
1826
1984
5327
3236
5871
5614
6196
6608
8143
5353
10516
6072
7857
8349
5754
5917
9114
9338
8023
9883
12062
3409
7104
16622
9424
7657
10159
14483
17052
17376
10832
8969
11347
13520
7084
19160
9582
9805
9878
15459
12964
13184
16248
10833
17572
26561
15218
27418
21389
25053
28744...

result:

wrong answer 1st lines differ - expected: '368', found: '369'