QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#407395 | #7988. 史莱姆工厂 | 11d10xy | WA | 47ms | 10468kb | C++17 | 1.5kb | 2024-05-08 17:16:42 | 2024-05-08 17:16:44 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
using i64=long long;
i64 L[160][160][11],R[160][160][11],g[160][160],h[160][160][11];
int n,K,cost,col[160],m[160],w[30];
//天真的想法会被2 3 2 3 2这种东西hack
//所以要找一些状态以保证不和左右相同
int main(){
memset(L,0xc0,sizeof(L)),memset(R,0xc0,sizeof(R)),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++)L[i][i][m[i]]=R[i][i][m[i]]=0,g[i][i]=-cost*(K-m[i])+w[K],g[i][i+1]=0;
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++){
if(col[l]!=col[r+1])eqmx(L[l][r][m[l]],g[l+1][r]);
if(col[r]!=col[l-1])eqmx(R[l][r][m[r]],g[l][r-1]);
for(int k=l;k<=r;k++)if(col[l]==col[k])for(int x=1;x<K-m[l];x++)eqmx(L[l][r][x+m[l]],g[l+1][k-1]+L[k][r][x]);
for(int k=l;k<=r;k++)if(col[r]==col[k])for(int x=1;x<K-m[r];x++)eqmx(R[l][r][x+m[r]],R[l][k][x]+g[k+1][r-1]);
for(int k=l;k<=r;k++)if(col[k]==col[r])for(int x=1;x<K;x++)eqmx(h[l][r][x],R[l][k][x]+g[k+1][r-1]);
for(int k=l;k<=r;k++)for(int x=1;x<K;x++)for(int y=K-x;y<K;y++)eqmx(g[l][r],h[l][k][x]+L[k][r][y]+w[x+y]);
for(int k=l;k<=r;k++)if(col[k]!=col[r+1])for(int x=1;x<K;x++)eqmx(g[l][r],R[l][k][x]+g[k+1][r]+w[K]-cost*(K-x));
for(int k=l;k<=r;k++)if(col[k]!=col[l-1])for(int x=1;x<K;x++)eqmx(g[l][r],L[k][r][x]+g[l][k-1]+w[K]-cost*(K-x));
}cout<<g[1][n];
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 10416kb
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: 0ms
memory: 10468kb
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: 47ms
memory: 10400kb
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: 44ms
memory: 10416kb
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:
9261940
result:
wrong answer 1st lines differ - expected: '9262990', found: '9261940'