QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#302612#7988. 史莱姆工厂PhantomThresholdWA 1ms3588kbC++202.1kb2024-01-11 00:24:142024-01-11 00:24:15

Judging History

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

  • [2024-01-11 00:24:15]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3588kb
  • [2024-01-11 00:24:14]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define int long long
using namespace std;

inline void up(int &a,const int &b){ if(a<b)a=b; }
const int maxn = 200;
const int maxk = 12;
const int inf  = 1e15;

int n,K,W;
int ci[maxn],mi[maxn];
int pi[maxn];

int f1[maxn][maxn][maxk],f2[maxn][maxn][maxk],g[maxn][maxn],fg[maxn][maxn][maxk];
//fg[maxn][maxn];

signed main()
{
	ios_base::sync_with_stdio(false);
	
	cin>>n>>K>>W;
	for(int i=1;i<=n;i++) cin>>ci[i];
	for(int i=1;i<=n;i++) cin>>mi[i];
	for(int i=K;i<=2*K-2;i++) cin>>pi[i];
	
	for(int i=1;i<=n;i++) 
	{
		for(int k=0;k<=K;k++) f1[i][i][k]=f2[i][i][k]=fg[i][i][k]=-inf;
		f1[i][i][mi[i]]=f2[i][i][mi[i]]=0;
		g[i][i]= pi[K]-W*(K-mi[i]);
		
		g[i][i-1]=0;
	}
	for(int L=2;L<=n;L++)
	{
		for(int r=L;r<=n;r++)
		{
			int l= r-L+1;
			
			g[l][r]=-inf;
			for(int k=0;k<=K;k++) f1[l][r][k]=f2[l][r][k]=fg[l][r][k]=-inf;
			
			if(l==1||ci[l-1]!=ci[r]) up(f1[l][r][mi[r]],g[l][r-1]);
			for(int mid=l;mid<r;mid++) if( ci[mid]==ci[r] )
			{
				if( l==1||ci[l-1]!=ci[mid]  )
				{
					for(int x=1;x+mi[r]<K;x++) 
						up(f1[l][r][x+mi[r]],f1[l][mid][x]+g[mid+1][r-1]);
				}
			}
			if(r==1||ci[l]!=ci[r+1]) up(f2[l][r][mi[l]],g[l+1][r]);
			for(int mid=l+1;mid<=r;mid++) if( ci[mid]==ci[l] )
			{
				if( r==1||ci[r+1]!=ci[mid] )
				{
					for(int x=1;x+mi[l]<K;x++)
						up(f2[l][r][x+mi[l]],g[l+1][mid-1]+f2[mid][r][x]);
				}
			}
			for(int mid=l;mid<r;mid++) if( ci[mid]==ci[r] )
			{
				if( l==1||ci[l-1]!=ci[mid] )
				{
					for(int x=1;x<K;x++)
						up(fg[l][r][x],f1[l][mid][x]+g[mid+1][r-1]);
				}
			}
			for(int mid=l+1;mid<=r;mid++)
			{
				if( r==n||ci[mid]!=ci[r+1] )
				{
					for(int x=1;x<K;x++) for(int y=1;y<K;y++) if(x+y>=K)
						up(g[l][r],fg[l][r][x]+f2[mid][r][y]+pi[x+y]);
				}
			}
			
			for(int mid=l;mid<=r;mid++)
			{
				//g+f
				if( (l==1||ci[l-1]!=ci[mid]) && (r==n||ci[mid]!=ci[r+1]) )
				{
					for(int y=1;y<K;y++) up(g[l][r],g[l][mid-1]+f1[mid][r][y]+pi[K]-W*(K-y));
				}
			}
		}
	}
	cout<<g[1][n]<<endl;
	
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3480kb

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: 1ms
memory: 3588kb

input:

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

output:

1950

result:

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