QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#717050#7988. 史莱姆工厂sslwcrWA 3ms54492kbC++142.2kb2024-11-06 16:44:312024-11-06 16:44:32

Judging History

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

  • [2024-11-06 16:44:32]
  • 评测
  • 测评结果:WA
  • 用时:3ms
  • 内存:54492kb
  • [2024-11-06 16:44:31]
  • 提交

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)
	{
		f[l][r]=mx(f[l][r],gtf(l,i-1)+gtf(i+1,r)+p[m[i]]);
		if (c[i]!=c[l-1]&&c[i]!=c[r+1]) 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,n);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 3ms
memory: 54016kb

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: 54492kb

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'