QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#406747#7988. 史莱姆工厂11d10xyWA 1ms8240kbC++171014b2024-05-07 17:22:562024-05-07 17:23:26

Judging History

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

  • [2024-05-07 17:23:26]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:8240kb
  • [2024-05-07 17:22:56]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using i64=long long;
i64 f[160][160][11],g[160][160],h[160][160][11];
int n,K,cost,col[160],m[160],w[30];
int main(){
   memset(f,0xc0,sizeof(f)),memset(g,0xc0,sizeof(g)),memset(h,0xc0,sizeof(h));
   cin>>n>>K>>cost;
   for(int i=1;i<=n;i++)cin>>col[i];
   for(int i=1;i<=n;i++)cin>>m[i];
   for(int i=K;i<=(K-1)*2;i++)cin>>w[i];
   for(int i=1;i<=n;i++)f[i][i][m[i]]=0,g[i][i]=-cost*(K-m[i])+w[K];
   auto eqmx=[](i64&x,i64 y){if(y>x)x=y;};
   for(int len=2;len<=n;len++)for(int l=1,r;(r=l+len-1)<=n;l++){
      for(int k=l;k<r;k++){
         eqmx(g[l][r],g[l][k]+g[k+1][r]);
         for(int x=1;x<K;x++)eqmx(h[l][r][x],f[l][k][x]+g[k+1][r]);
         if(col[l]==col[r])for(int x=1;x<K;x++)for(int y=1;y<K;y++)
         if(x+y>=K)eqmx(g[l][r],h[l][k][x]+f[k+1][r][y]+w[x+y]);
         else eqmx(f[l][r][x+y],h[l][k][x]+f[k+1][r][y]);
      }
      for(int x=1;x<K;x++)eqmx(g[l][r],f[l][r][x]-cost*(K-x)+w[K]);
   }cout<<g[1][n];
   return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 8100kb

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

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'