QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#534606 | #7988. 史莱姆工厂 | Ecrade_ | WA | 56ms | 23624kb | C++14 | 2.0kb | 2024-08-27 14:22:44 | 2024-08-27 14:22:45 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,w,p[20],a[159],c[159],f[159][159],g[159][159][10][10],h[159];
inline ll read(){
ll s = 0,w = 1;
char ch = getchar();
while (ch > '9' || ch < '0'){ if (ch == '-') w = -1; ch = getchar();}
while (ch <= '9' && ch >= '0') s = (s << 1) + (s << 3) + (ch ^ 48),ch = getchar();
return s * w;
}
inline void chkmax(ll &x,ll y){if (x < y) x = y;}
int main(){
n = read(),m = read(),w = read();
for (ll i = 1;i <= n;i += 1) c[i] = read();
for (ll i = 1;i <= n;i += 1) a[i] = read();
for (ll i = m;i <= 2 * m - 2;i += 1) p[i] = read();
for (ll i = 1;i <= n;i += 1) for (ll j = 1;j <= n;j += 1){
f[i][j] = -1e18;
for (ll k = 0;k < m;k += 1) for (ll l = 0;l < m;l += 1) g[i][j][k][l] = -1e18;
}
for (ll i = n;i >= 1;i -= 1){
ll cnt = 0;
for (ll j = i;j <= n;j += 1){
cnt += (c[i] == c[j]) * a[j];
if (i == j){
f[i][j] = p[m] - w * (m - a[i]);
g[i][j][a[i]][0] = 0;
continue;
}
ll res = -1e18;
for (ll k = 0;k <= min(m - 1,cnt);k += 1){
for (ll l = 0;l <= m - 1 && k + l <= cnt;l += 1){
if (c[i] == c[j]){
if (k >= a[j] && !l) chkmax(g[i][j][k][l],g[i][j - 1][k - a[j]][l]);
if (l >= a[j]) chkmax(g[i][j][k][l],g[i][j - 1][k][l - a[j]]);
// if (i == 2 && j == 4) cout<<k<<' '<<l<<' '<<g[i][j][k][l]<<"HHH"<<endl;
if (k + l < m) chkmax(res,g[i][j][k][l] + p[m] - w * (m - k - l));
else chkmax(res,g[i][j][k][l] + p[k + l]);
}
else{
for (ll o = i;o < j;o += 1){
chkmax(g[i][j][k][l],g[i][o][k][l] + f[o + 1][j]);
// if (i == 1 && j == 2) cout<<k<<' '<<l<<' '<<o<<' '<<g[i][j][k][l]<<"WTF"<<endl;
}
}
}
}
if (c[i] == c[j]) f[i][j] = res;
}
}
// for (ll i = 1;i <= n;i += 1) for (ll j = i;j <= n;j += 1) cout<<i<<'.'<<j<<' '<<f[i][j]<<endl;
for (ll i = 1;i <= n;i += 1){
h[i] = -1e18;
for (ll j = 1;j <= i;j += 1) chkmax(h[i],h[j - 1] + f[j][i]);
}
printf("%lld",h[n]);
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3816kb
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: 1ms
memory: 6016kb
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: 52ms
memory: 22712kb
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: 56ms
memory: 23624kb
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:
9260890
result:
wrong answer 1st lines differ - expected: '9262990', found: '9260890'