QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#519383#7988. 史莱姆工厂hewanyingWA 50ms24144kbC++141.4kb2024-08-14 19:22:572024-08-14 19:22:57

Judging History

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

  • [2024-08-14 19:22:57]
  • 评测
  • 测评结果:WA
  • 用时:50ms
  • 内存:24144kb
  • [2024-08-14 19:22:57]
  • 提交

answer

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

const int N=155,M=55,inf=1e18;
int n,m,V[N],val,fl[N][N][M],f[N][N],g[N][N][M],c[N],w[N];

void ckmx(int &a,int b){a=max(a,b);}

signed main(){
  /*2024.8.12 H_W_Y P10041 [CCPC 2023 北京市赛] 史莱姆工厂 区间 dp*/
  ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  cin>>n>>m>>val;
  for(int i=1;i<=n;i++) cin>>c[i];
  for(int i=1;i<=n;i++) cin>>w[i];
  for(int i=m;i<=2*m-2;i++) cin>>V[i];

  for(int l=1;l<=n;l++)
    for(int r=1;r<=n;r++){
	  f[l][r]=-inf;
	  for(int p=1;p<=m;p++) fl[l][r][p]=g[l][r][p]=-inf;
	}
  for(int i=1;i<=n;i++)
	f[i][i]=V[m]-(m-w[i])*val,fl[i][i][w[i]]=0;

  for(int i=2;i<=n;i++)
    for(int l=1,r=i;r<=n;l++,r++){
	  fl[l][r][w[l]]=f[l+1][r];

	  for(int k=l+1;k<=r;k++)
	    if(c[k]==c[l])
	      for(int p=w[l]+1;p<m;p++)
		    ckmx(fl[l][r][p],f[l+1][k-1]+fl[k][r][p-w[l]]);
	  
	  for(int k=l;k<=r;k++)
		if(c[k]==c[r+1])	  
	      for(int p=1;p<m;p++)
		    ckmx(g[l][r][p],f[l][k-1]+fl[k][r][p]);
	  
	  for(int k=l;k<=r;k++)
	    if(c[l-1]!=c[k]&&c[r+1]!=c[k])
	      for(int p=1;p<m;p++)
		    ckmx(f[l][r],f[l][k-1]+fl[k][r][p]-(m-p)*val+V[m]);
	  for(int k=l+1;k<=r;k++)
		if(c[l-1]!=c[k]&&c[k]!=c[r+1])	  
	      for(int p=1;p<m;p++)
	        for(int u=1;u<m;u++)
		      if(p+u>=m)
		        ckmx(f[l][r],g[l][k-1][p]+fl[k][r][u]+V[p+u]);
	}
  cout<<f[1][n];
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 0
Accepted
time: 1ms
memory: 5628kb

input:

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

output:

1400

result:

ok single line: '1400'

Test #3:

score: 0
Accepted
time: 46ms
memory: 24016kb

input:

150 10 465782
6 1 4 3 2 6 1 3 5 3 4 6 1 2 1 5 1 6 2 1 5 4 6 1 3 2 6 5 4 3 1 6 3 4 1 4 1 6 3 6 1 4 2 4 6 4 3 1 5 6 4 2 1 4 6 2 5 1 3 1 4 6 5 6 3 2 3 4 2 3 6 3 5 2 6 1 5 4 5 2 4 1 4 3 4 1 3 2 6 1 4 5 4 6 2 1 3 1 2 1 3 5 2 3 2 6 5 3 1 4 1 5 1 6 2 5 4 2 4 1 4 2 5 6 4 3 5 1 3 2 5 4 6 4 3 5 3 4 5 3 2 1 4 ...

output:

392867316

result:

ok single line: '392867316'

Test #4:

score: -100
Wrong Answer
time: 50ms
memory: 24144kb

input:

150 10 10105
8 6 8 6 8 3 8 5 8 5 1 5 1 5 6 5 6 5 6 7 6 5 6 1 6 4 6 4 3 4 9 4 1 4 1 4 1 5 1 9 1 4 1 9 1 9 3 9 1 9 5 9 8 9 8 5 8 7 8 4 8 6 8 6 2 6 9 6 4 6 5 6 5 3 5 1 5 4 5 8 5 8 9 8 7 8 6 8 1 8 1 8 1 8 1 6 1 7 1 7 2 7 4 7 6 7 4 7 4 5 4 7 4 7 4 3 4 3 7 3 2 3 8 3 4 3 4 8 4 7 4 9 4 2 4 2 7 2 8 2 7 2 9 2...

output:

9260890

result:

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