QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#325764#7988. 史莱姆工厂HanghangWA 3ms10996kbC++141.4kb2024-02-11 21:58:302024-02-11 21:58:31

Judging History

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

  • [2024-02-11 21:58:31]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:10996kb
  • [2024-02-11 21:58:30]
  • 提交

answer

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

typedef long long ll;
const ll N=153,M=13,INF=(ll)1e18;
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];
	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++)
	{
		for(int k=l;k<=r;k++)Max(f[l][r],f[l][k]+f[k+1][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],fr[l][k][p]+f[k+1][r]+b[m]-w*(m-p));
		for(int k=l;k<r;k++)if(c[k]==c[r]&&c[l-1]!=c[k])
		    for(int p=1;p<m;p++)Max(g[l][r][p],fr[l][k][p]+f[k+1][r-1]);
		for(int k=l+1;k<=r;k++)if(c[k]!=c[r+1])
		    for(int x=1;x<m;x++)for(int y=1;y<m;y++)Max(f[l][r],g[l][k][x]+fl[k][r][y]+b[x+y]);
	}
	cout<<f[1][n];
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 10996kb

input:

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

output:

-1

result:

ok single line: '-1'

Test #2:

score: -100
Wrong Answer
time: 3ms
memory: 10904kb

input:

5 7 500
2 3 2 3 2
5 6 6 6 4
1000 900 800 400 200 50

output:

2300

result:

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