QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#205385#7567. Joining Catsucup-team866#RE 1ms5588kbC++14694b2023-10-07 15:45:232023-10-07 15:45:23

Judging History

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

  • [2023-10-07 15:45:23]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:5588kb
  • [2023-10-07 15:45:23]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n, m, w[5005], s[5005], dp[5005][5005], r[5005];
int main() {
	cin >> n >> m;
	for (int i=1; i<=n; i++)
		scanf ("%d", &w[i]);
	for (int i=1; i<=m; i++)
		scanf ("%d", &s[i]);
	for (int i=0; i<=m; i++)
		for (int j=1; j<=n; j++)
			dp[i][j] = j;
	for (int i=1; i<=m; i++) {
		int p = r[n+1] = n, t = 0;
		for (int j=n; j; j--) {
			t += w[j];
			while (t > s[i]) t -= w[p--];
			r[j] = p;
		}
		p = 1, t = 0;
		for (int j=1; j<=n; j++) {
			dp[i][t] = max(dp[i][t], dp[i-1][j]);
			dp[i][j] = max(dp[i][j], r[dp[i-1][j]+1]);
			t += w[j];
			while (t > s[i]) t -= w[p++];
		}
	} puts (dp[m][1] == n ? "Yes" : "No");
}

详细

Test #1:

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

input:

5 2
1 1 1 1 1
2 2

output:

Yes

result:

ok answer is YES

Test #2:

score: 0
Accepted
time: 1ms
memory: 5588kb

input:

6 7
3 2 1 1 2 3
2 2 2 2 2 2 2

output:

No

result:

ok answer is NO

Test #3:

score: 0
Accepted
time: 0ms
memory: 3460kb

input:

7 4
1 2 3 4 3 2 1
3 3 3 3

output:

Yes

result:

ok answer is YES

Test #4:

score: 0
Accepted
time: 0ms
memory: 3744kb

input:

5 1
5 4 3 2 1
10

output:

Yes

result:

ok answer is YES

Test #5:

score: -100
Runtime Error

input:

5000 5000
775487425 856128884 277783434 903422359 477267301 475103384 297595527 426167697 732858986 408894759 274205836 78265305 841664344 827278645 235744961 539622829 661053351 709331224 497285040 688977639 794889854 890450616 730989757 164925481 519732355 5132018 793806705 617096813 966338860 838...

output:


result: