QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#271063#5303. No Bug No GamearahatoWA 69ms4764kbC++14859b2023-12-01 22:04:322023-12-01 22:04:33

Judging History

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

  • [2023-12-01 22:04:33]
  • 评测
  • 测评结果:WA
  • 用时:69ms
  • 内存:4764kb
  • [2023-12-01 22:04:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int N=3005;
int f[N][2],g[N][2],n,m,a[N][15],p[N],sump[N];
bitset<3001> cpo[N];

signed main(){
	ios::sync_with_stdio(0);
	cin>>n>>m;
	for(int i=1;i<=n;i++){
		cin>>p[i];
		for(int j=1;j<=p[i];j++) cin>>a[i][j];
		sump[i]=sump[i-1]+p[i];
	}
	if(sump[n]<=m){
		int ans=0;
		for(int i=1;i<=n;i++) ans+=a[i][p[i]];
		cout<<ans;
		return 0;
	}
	cpo[n+1][0]=1;
	for(int i=n;i;i--){
		cpo[i]=cpo[i+1]|(cpo[i+1]<<p[i]);
	}
	memset(f,-60,sizeof f);
	memset(g,-60,sizeof g);
	f[0][0]=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=m;j++) for(int o:{0,1}) if(j>=p[i]){
			g[j][o]=max(g[j][o],f[j-p[i]][o]+a[i][p[i]]);
		}
		for(int k=1;k<=p[i];k++) for(int j=k;j<=m;j++) if(cpo[i+1][m-j]){
			g[j][1]=max(g[j][1],f[j-k][0]+a[i][k]);
		}
		memcpy(f,g,sizeof f);
	}
	cout<<f[m][1];
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 69ms
memory: 4764kb

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:

68250371

result:

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