QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#717327 | #7988. 史莱姆工厂 | juan_123 | WA | 1ms | 5680kb | C++14 | 2.4kb | 2024-11-06 17:37:57 | 2024-11-06 17:37:58 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int inf = 10000000000000;
int dp[20505][205][10];
// [l,r] 只剩一个数颜色为 c 大小为 k
int n,K,w;
int id[205][205];int nw =0 ;
int c[205],m[205],p[205];
signed main(){
//freopen("basketball.in","r",stdin);
//freopen("basketball.out","w",stdout);
cin >> n >>K >> w;
for(int i = 1;i<=n;i++)cin >> c[i];
for(int i = 1;i<=n;i++)cin >> m[i];
for(int i = K;i<=2*K-2;i++)cin >> p[i];
for(int i = 1;i<=n;i++)for(int j = i-1;j<=n;j++)id[i][j] = ++nw;
for(int i =1;i<=n;i++)for(int j = 1;j<=n;j++)for(int k = 0;k<=n;k++)for(int l = 0;l<=K;l++)dp[id[i][j]][k][l] = -inf;
for(int i =1;i<=n+1;i++){
dp[id[i][i-1]][0][0] = 0;
}
for(int i = 1;i<=n;i++)dp[id[i][i]][c[i]][m[i]] = 0;
for(int i = 1;i<=n;i++){
for(int j =m[i]+1;j<K;j++)dp[id[i][i]][c[i]][j] = -w*(j-m[i]);
dp[id[i][i]][0][0] = -w*(K-m[i])+p[K];
// cout << " " << i << " " << m[i] << " " << dp[i][i][0][0] << endl;
}
for(int len = 2;len<=n;len++){
for(int l = 1;l+len-1<=n;l++){
int r = l+len-1;
for(int k = l;k<r;k++){
vector<pair<int,int> >p1,p2;
for(int c = 1;c<=n;c++){
for(int k1 = 1;k1<K;k1++){
if(dp[id[l][k]][c][k1]==-inf)continue;
for(int k2 =1;k2<K;k2++){
if(dp[id[k+1][r]][c][k2] == -inf)continue;
int sumv = k1+k2;
if(sumv>=K){
dp[id[l][r]][0][0] = max(dp[id[l][r]][0][0],dp[id[l][k]][c][k1]+dp[id[k+1][r]][c][k2]+p[sumv]);
}else{
dp[id[l][r]][c][k1+k2] = max(dp[id[l][r]][c][k1+k2],dp[id[l][k]][c][k1]+dp[id[k+1][r]][c][k2]);
}
}
}
for(int k1 =0;k1<K;k1++){
dp[id[l][r]][c][k1] = max(dp[id[l][r]][c][k1],dp[id[l][k]][c][k1]+dp[id[k+1][r]][0][0]);
dp[id[l][r]][c][k1] = max(dp[id[l][r]][c][k1],dp[id[l][k]][0][0]+dp[id[k+1][r]][c][k1]);
}
dp[id[l][r]][0][0] = max(dp[id[l][r]][0][0],dp[id[l][k]][0][0]+dp[id[k+1][r]][0][0]);
}
}
for(int c = 1;c<=n;c++){
for(int k =1;k<K;k++)dp[id[l][r]][c][k] = max(dp[id[l][r]][c][k],dp[id[l][r]][c][k-1]-w);
dp[id[l][r]][0][0] = max(dp[id[l][r]][0][0],dp[id[l][r]][c][K-1]-w+p[K]);
}
}
}
// for(int i = 1;i<=n;i++){
// for(int j = i;j<=n;j++){
// cout << dp[i][j][0][0] << " ";
// }
// cout << endl;
// }
cout << dp[id[1][n]][0][0] << endl;
return 0;
}/*
6 4 3
2 1 3 1 3 2
3 2 1 2 2 2
5 7 7
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3752kb
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: 5680kb
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'