QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#440542 | #7988. 史莱姆工厂 | MEKHANE | WA | 2ms | 7736kb | C++14 | 1.0kb | 2024-06-13 20:26:03 | 2024-06-13 20:26:03 |
Judging History
answer
#include<bits/stdc++.h>
#define int long long
#define rep(i,j,k) for(int i=j;i<=k;i++)
using namespace std;
const int N=151,M=11;
int n,K,W,c[N],w[N],p[2*M],f[N][N],g1[N][N][M],g2[N][N][M];
signed main(){
ios::sync_with_stdio(false);
cin>>n>>K>>W,memset(f,-0x3f,sizeof(f)),memset(g1,-0x3f,sizeof(g1)),memset(g2,-0x3f,sizeof(g2));
rep(i,1,n) cin>>c[i];
rep(i,1,n) cin>>w[i];
rep(i,K,2*K-2) cin>>p[i];
rep(i,1,n){
f[i][i]=p[K]-(K-w[i])*W;
rep(x,w[i],K-1) g1[i][i][x]=-(x-w[i])*W;
}
rep(cd,2,n) rep(l,1,n-cd+1){
int r=l+cd-1;
rep(k,l,r-1) f[l][r]=max(f[l][r],f[l][k]+f[k+1][r]);
if(c[l]==c[r]){
rep(k,l,r-1) rep(x,1,K-1) rep(y,1,K-1) if(x+y>=K) f[l][r]=max(f[l][r],g2[l][k][x]+g1[k+1][r][y]+p[x+y]);
rep(x,1,K-1) rep(y,1,K-1) if(x+y<K) g1[l][r][x+y]=max(g1[l][r][x+y],g2[l][r-1][x]+g1[r][r][y]);
}
rep(k,l,r-1) rep(x,1,K-1) g2[l][r][x]=max(g2[l][r][x],g1[l][k][x]+f[k+1][r]);
}cout<<f[1][n];
}
詳細信息
Test #1:
score: 100
Accepted
time: 2ms
memory: 7672kb
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: 7736kb
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'