QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#516775#7988. 史莱姆工厂hewanyingWA 1ms9844kbC++141.4kb2024-08-12 21:28:442024-08-12 21:28:44

Judging History

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

  • [2024-08-12 21:28:44]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:9844kb
  • [2024-08-12 21:28:44]
  • 提交

answer

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

const int N=155,M=55,inf=2e9;
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 p=w[l]+1;p<m;p++)
	    for(int k=l+1;k<r;k++)
		  ckmx(fl[l][r][p],f[l+1][k]+fl[k+1][r][p-w[l]]);
	  
	  if(c[l]==c[r]) for(int p=1;p<m;p++) g[l][r][p]=fl[l][r-1][p];
	  for(int p=1;p<m;p++)
	    for(int k=l;k<r-1;k++)
		  if(c[k+1]==c[r])
		    ckmx(g[l][r][p],f[l][k]+fl[k+1][r-1][p]);
	  
	  for(int p=1;p<m;p++) ckmx(f[l][r],fl[l][r][p]-(m-p)*val+V[m]);
	  for(int k=l;k<r;k++)
	    for(int p=1;p<m;p++)
		  ckmx(f[l][r],f[l][k]+fl[k+1][r][p]-(m-p)*val+V[m]);
	  for(int p=1;p<m;p++)
	    for(int u=1;u<m;u++)
		  for(int k=l+1;k<=r;k++)
		    ckmx(f[l][r],g[l][k][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: 5776kb

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

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'