QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#396651#7988. 史莱姆工厂zyxawaWA 0ms10960kbC++141.5kb2024-04-22 23:01:552024-04-22 23:01:56

Judging History

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

  • [2024-04-22 23:01:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:10960kb
  • [2024-04-22 23:01:55]
  • 提交

answer

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

typedef long long ll;
const ll N=153,M=13;
ll n,m,w,a[N],b[N],c[N],f[N][N],fl[N][N][M],fr[N][N][M],g[N][N][M];
void Max(ll &x,ll y){if(x<y)x=y;}
int main()
{
	cin>>n>>m>>w;
	for(int i=1;i<=n;i++)cin>>c[i];
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=m;i<=2*m-2;i++)cin>>b[i];
	for(int i=1;i<m;i++) b[i]=b[m]-(m-i)*w;
	memset(f,-0x3f,sizeof(f));memset(g,-0x3f,sizeof(g));
	memset(fl,-0x3f,sizeof(fl));memset(fr,-0x3f,sizeof(fr));
	for(int i=1;i<=n;i++)
	    fl[i][i][a[i]]=fr[i][i][a[i]]=f[i][i-1]=0,f[i][i]=b[m]-w*(m-a[i]);
	for(int len=2;len<=n;len++)for(int l=1,r=len;r<=n;l++,r++)
	{
		if(c[l-1]!=c[r])Max(fr[l][r][a[r]],f[l][r-1]);
		for(int k=l;k<r;k++)if(c[k]==c[r]&&c[l-1]!=c[k])
		    for(int p=1;p+a[r]<m;p++)Max(fr[l][r][p+a[r]],fr[l][k][p]+f[k+1][r-1]);
		if(c[l]!=c[r+1])Max(fl[l][r][a[l]],f[l+1][r]);
		for(int k=l+1;k<=r;k++)if(c[k]==c[l]&&c[r+1]!=c[k])
		    for(int p=1;p+a[l]<m;p++)Max(fl[l][r][p+a[l]],fl[k][r][p]+f[l+1][k-1]);
		for(int k=l;k<=r;k++)if(c[k]!=c[l-1]&&c[k]!=c[r+1])
		    for(int p=1;p<m;p++)Max(f[l][r],f[l][k-1]+fl[k][r][p]+b[m]-w*(m-p));
		for(int k=l;k<=r;k++)if(c[k]!=c[l-1]&&c[k]!=c[r+1])
		    for(int p=1;p<m;p++)Max(f[l][r],fr[l][k][p]+f[k+1][r]+b[m]-w*(m-p));
		for(int k=l;k<r;k++){
				for(int i=1;i<m;i++){
					for(int j=1;j<m;j++){
						if(c[l]!=c[l-1]&&c[r]!=c[r+1]) Max(f[l][r],fl[l][k][i]+fr[k+1][r][j]+b[i+j]);
					}
				}
			}
	}
	cout<<f[1][n];
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

16

result:

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