QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#279600#5303. No Bug No Gamezzuqy#WA 18ms74288kbC++11869b2023-12-08 21:53:102023-12-08 21:53:10

Judging History

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

  • [2023-12-08 21:53:10]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:74288kb
  • [2023-12-08 21:53:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int read()
{
    int x;cin>>x;
    return x;
}
int n,k,p[3010];
int w[3010][12],f[3010][3010],g[3010][3010],sum;
int main()
{
	// freopen("1.in","r",stdin);
	n=read();k=read();
	for(int i=1;i<=n;i++)
	{
		p[i]=read();
		for(int j=1;j<=p[i];j++)
			w[i][j]=read();
		sum+=p[i];
	}
	if(sum<=k)
	{
		int ans=0;
		for(int i=1;i<=n;i++)
			ans=ans+w[i][p[i]];
		cout<<ans;
		return 0;
	}
	int ans=0;
	for(int i=1;i<=n;i++)
		for(int j=0;j+p[i]<=3000;j++)
			f[i][j+p[i]]=max(f[i-1][j+p[i]],f[i-1][j]+w[i][p[i]]);
	for(int i=n;i>=1;i--)
		for(int j=0;j+p[i]<=3000;j++)
			g[i][j+p[i]]=max(g[i+1][j+p[i]],g[i-1][j]+w[i][p[i]]);
	for(int i=1;i<=n;i++)
		for(int x=1;x<=p[i];x++)
			for(int y=0;x+y<=k;y++)
				ans=max(ans,w[i][x]+f[i-1][k-x-y]+g[i-1][y]);
	cout<<ans;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3684kb

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: 18ms
memory: 74288kb

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:

68230916

result:

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