QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#100138#5303. No Bug No Gamelgvc#WA 156ms75596kbC++232.3kb2023-04-24 19:54:402023-04-24 19:54:41

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-04-24 19:54:41]
  • 评测
  • 测评结果:WA
  • 用时:156ms
  • 内存:75596kb
  • [2023-04-24 19:54:40]
  • 提交

answer

//这回只花了114514min就打完了。
//真好。记得多手造几组。
#include <bits/stdc++.h>
//#define int long long
#define pai 3.141592653589793238462643383279502884197169399375105820
#define MOD 1000000007
#define eps 0.00000001
inline int min(int a,int b) {return a<b?a:b;}
inline int max(int a,int b) {return a>b?a:b;}
#define ULL unsigned long long
#define LL long long
#define INF 0x3f3f3f3f
#define INF_LL 0x3f3f3f3f3f3f3f3f
static char buf[1000000],*paa=buf,*pd=buf;
static char buf2[1000000],*pp=buf2;
#define getchar() paa==pd&&(pd=(paa=buf)+fread(buf,1,1000000,stdin),paa==pd)?EOF:*paa++
inline void pc(char ch){
	if(pp-buf2==1000000) fwrite(buf2,1,1000000,stdout),pp=buf2;
	*pp++=ch;
}
inline void pcc(){
	fwrite(buf2,1,pp-buf2,stdout);
	pp=buf2;
}
inline int read(void) {
	int w=1;
	register int x(0);register char c(getchar());
	while(c<'0'||c>'9') {if(c=='-') w=-1;c=getchar();}
	while(c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
	return w*x;
}
void write(int x) {
	if(x<0) pc('-'),x=-x;
	static int sta[20];
	int top=0;
	do {
		sta[top++]=x%10,x/=10;
	} while(x);
	while(top) pc(sta[--top]+48);
}
void we(int x) {
	write(x);
	pc('\n');
}
inline bool cmp_xi(int a,int b) {return a<b;}
inline bool cmp_da(int a,int b) {return a>b;}
int N,K,dp1[3009][3009],p[3009],dp2[3009][3009],a[3009][19],as;
signed main(void) {
    //freopen("m.in","r",stdin);
    //freopen("m.out","w",stdout);
	N=read();K=read();
	memset(dp1,-0x3f,sizeof(dp1));
	memset(dp2,-0x3f,sizeof(dp2));
	dp1[0][0]=dp2[N+1][0]=0;
	for(int i=1;i<=N;i++) {
		p[i]=read();
		for(int j=1;j<=p[i];j++) {
			a[i][j]=read();
		}
	}
	for(int i=1;i<=N;i++) {
		for(int j=0;j<=K;j++) {
			dp1[i][j]=dp1[i-1][j];
			for(int k=1;k<=p[i]&&k<=j;k++) {
				dp1[i][j]=std::max(dp1[i][j],dp1[i-1][j-k]+a[i][k]);
			}
		}		
	}
	for(int i=N;i>=1;i--) {
		for(int j=0;j<=K;j++) {
			dp2[i][j]=dp2[i+1][j];
			for(int k=1;k<=p[i]&&k<=j;k++) {
				dp2[i][j]=std::max(dp2[i][j],dp2[i+1][j-k]+a[i][k]);
			}
		}		
	}
	for(int i=1;i<=N;i++) {
		for(int j=0;j<=p[i]&&j<=K;j++) {
			int ans=-INF;
			for(int l=0;l<=K-j;l++) {
				ans=std::max(ans,dp1[i-1][l]+dp2[i+1][K-j-l]);
			}
			as=std::max(as,ans+a[i][j]);
		}
	}
	printf("%d",as);
    return 0;
}


Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 8ms
memory: 74444kb

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: 156ms
memory: 75596kb

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:

171648352

result:

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