QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#717110#7988. 史莱姆工厂sslwcrWA 0ms55240kbC++142.2kb2024-11-06 16:56:492024-11-06 16:56:49

Judging History

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

  • [2024-11-06 16:56:49]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:55240kb
  • [2024-11-06 16:56:49]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<queue>
#include<array>
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007ll
using namespace std;
inline int read()
{
	int ret,c,f=1;
	while (((c=getchar())> '9'||c< '0')&&c!='-');
	if (c=='-') f=-1,ret=0;
	else ret=c-'0';
	while ((c=getchar())>='0'&&c<='9') ret=ret*10+c-'0';
	return ret*f;
}
int n,k,w,c[202],m[202],p[202];
int f[202][202],g1[202][202][12],g2[202][202][12][12];
bool visf[202][202],visg1[202][202][12],visg2[202][202][12][12];
inline int mx(int x,int y)
{
	return x>y?x:y;
}
int gtf(int l,int r);
int gtg2(int l,int r,int s1,int s2);
int gtg1(int l,int r,int s1);
int gtf(int l,int r)
{
	if (l>r) return 0;
	if (visf[l][r]) return f[l][r];
	visf[l][r]=1;
	if (l==r)
	{
		f[l][r]=p[m[r]];
		return f[l][r];
	}
	for (int i=l;i<=r;++i)
	{
		if (c[i]!=c[l-1]&&c[i]!=c[r+1])
		{
			f[l][r]=mx(f[l][r],gtf(l,i-1)+gtf(i+1,r)+p[m[i]]);
			for (int s1=1;s1<k;++s1) for (int s2=1;s2<k;++s2)
			{
				f[l][r]=mx(f[l][r],gtg2(l,i,s1,s2)+gtf(i+1,r)+p[s1+s2]);
			}
		}
	}
	return f[l][r];
}
int gtg1(int l,int r,int s)
{
	if (l>r) return 0;
	if (visg1[l][r][s]) return g1[l][r][s];
	visg1[l][r][s]=1;
	if (s==m[r]) g1[l][r][s]=mx(g1[l][r][s],gtf(l,r-1));
	if (s>m[r]) for (int i=l;i<r;++i)
	{
		if (c[i]==c[r]) g1[l][r][s]=mx(g1[l][r][s],gtf(i+1,r-1)+gtg1(l,i,s-m[r]));
	}
	return g1[l][r][s];
}
int gtg2(int l,int r,int s1,int s2)
{
	if (l>r) return 0;
	if (visg2[l][r][s1][s2]) return g2[l][r][s1][s2];
	visg2[l][r][s1][s2]=1;
	if (s2==m[r])
	{
		for (int i=l;i<r;++i) if (c[i]==c[r])
		{
			g2[l][r][s1][s2]=max(g2[l][r][s1][s2],gtg1(l,i,s1)+gtf(i+1,r-1));
		}
	}
	if (s2>m[r]) for (int i=l;i<r;++i) if (c[i]==c[r])
	{
		g2[l][r][s1][s2]=max(g2[l][r][s1][s2],gtg2(l,i,s1,s2-m[r])+gtf(i+1,r-1));
	}
	return g2[l][r][s1][s2];
}
signed main()
{
	n=read(),k=read(),w=read();
	for (int i=1;i<=n;i++) c[i]=read();
	for (int i=1;i<=n;i++) m[i]=read();
	for (int i=k;i<=2*k-2;i++) p[i]=read();
	for (int i=0;i<k;i++) p[i]=p[k]-(k-i)*w;
	memset(f,-0x3f,sizeof(f));
	memset(g1,-0x3f,sizeof(g1));
	memset(g2,-0x3f,sizeof(g2));
	cout<<gtf(1,5);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

-26

result:

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