QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#235834#5303. No Bug No Gameushg8877#WA 23ms144896kbC++20903b2023-11-03 10:48:012023-11-03 10:48:02

Judging History

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

  • [2023-11-03 10:48:02]
  • 评测
  • 测评结果:WA
  • 用时:23ms
  • 内存:144896kb
  • [2023-11-03 10:48:01]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MP make_pair
mt19937 rnd(time(0));
const int MAXN=3005;
ll f[MAXN][MAXN],g[MAXN][MAXN];
int n,k,s,p[MAXN];ll w[MAXN][15];
int main(){
	ios::sync_with_stdio(false);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>p[i];
		for(int j=1;j<=p[i];j++) cin>>w[i][j];
		s+=p[i];
	}
	if(s<=k){
		ll ans=0;
		for(int i=1;i<=n;i++) ans+=w[i][p[i]];
		cout<<ans<<endl;return 0;
	}
	memset(f,-0x3f,sizeof(f));memset(g,-0x3f,sizeof(g));
	f[0][0]=0;
	auto cmax=[&](ll &x,ll y){if(x<y)x=y;}; 
	for(int i=1;i<=n;i++){
		for(int j=p[i];j<=k;j++){
			cmax(f[i][j],f[i-1][j]);cmax(f[i][j],f[i-1][j-p[i]]+w[i][p[i]]);
			cmax(g[i][j],g[i-1][j]);cmax(g[i][j],g[i-1][j-p[i]]+w[i][p[i]]);
		}
		for(int j=1;j<=p[i];j++) for(int t=j;t<=k;t++){
			cmax(g[i][t],f[i-1][t-j]+w[i][j]);
		}
	}
	cout<<g[n][k]<<endl;
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 23ms
memory: 144896kb

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:

68233938

result:

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