QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#396661#7988. 史莱姆工厂zyxawaWA 0ms11396kbC++141.2kb2024-04-22 23:19:572024-04-22 23:19:58

Judging History

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

  • [2024-04-22 23:19:58]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:11396kb
  • [2024-04-22 23:19:57]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n,s,w,c[151],m[151],p[21];
ll f[151][151],fl[151][151][21],fr[151][151][21];
void upd(ll &x,ll y){x=max(x,y);}
int main(){
	memset(f,-0x3f,sizeof(f)),memset(fl,-0x3f,sizeof(fl)),memset(fr,-0x3f,sizeof(fr));
	scanf("%d%d%d",&n,&s,&w);
	for(int i=1;i<=n;i++) scanf("%d",&c[i]);
	for(int i=1;i<=n;i++) scanf("%d",&m[i]);
	for(int i=s;i<=2*s-2;i++) scanf("%d",&p[i]);
	for(int i=1;i<s;i++) p[i]=p[s]-(s-i)*w;
	for(int i=1;i<=n;i++) f[i][i]=p[m[i]],f[i][i-1]=0;
	for(int t=2;t<=n;t++){
		for(int l=1;l+t-1<=n;l++){
			int r=l+t-1;
			upd(fl[l][r][m[l]],f[l+1][r]);
			for(int k=l+1;k<=r;k++) if(c[l]==c[k]) for(int i=1;i<s-m[l];i++) upd(fl[l][r][i+m[l]],f[l+1][k-1]+fl[k][r][i]);
			upd(fr[l][r][m[r]],f[l][r-1]);
			for(int k=l;k<r;k++) if(c[r]==c[k]) for(int i=1;i<s-m[r];i++) upd(fr[l][r][i+m[r]],f[k+1][r-1]+fr[l][k][i]);
			for(int k=l;k<r;k++) if(c[k]!=c[r+1]||c[k+1]!=c[l-1]) upd(f[l][r],f[l][k]+f[k+1][r]);
			if(c[l]!=c[r]) continue;
			for(int k=l;k<r;k++) for(int i=1;i<s;i++) for(int j=1;j<s;j++) upd(f[l][r],fl[l][k][i]+fr[k+1][r][j]+p[i+j]);
		}
	}
	printf("%lld",f[1][n]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 11396kb

input:

4 5 6
2 1 2 3
3 3 3 4
5 7 9 11

output:

-22

result:

wrong answer 1st lines differ - expected: '-1', found: '-22'