QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#353543 | #7988. 史莱姆工厂 | alpha1022 | WA | 6ms | 6144kb | C++14 | 1.4kb | 2024-03-14 10:56:59 | 2024-03-14 10:56:59 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll inf = 0x3f3f3f3f3f3f3f3f;
const int N = 150;
const int M = 10;
int n, m, w;
int c[N + 5], a[N + 5], p[M];
ll f[N + 5][N + 5], g[N + 5][N + 5], h[N + 5][N + 5][M];
int main() {
scanf("%d%d%d", &n, &m, &w);
for (int i = 1; i <= n; ++i) scanf("%d", c + i);
for (int i = 1; i <= n; ++i) scanf("%d", a + i);
for (int i = 0; i < m - 1; ++i) scanf("%d", p + i);
memset(f, -0x3f, sizeof f), memset(g, -0x3f, sizeof g), memset(h, -0x3f, sizeof h);
for (int i = 0; i <= n; ++i) f[i + 1][i] = 0;
for (int l = n; l; --l)
for (int r = l; r <= n; ++r) {
h[l][r][a[r]] = f[l][r - 1];
for (int k = l; k + 1 < r; ++k)
if (c[k] == c[r])
for (int i = a[r]; i < m; ++i)
h[l][r][i] = max(h[l][r][i], h[l][k][i - a[r]] + f[k + 1][r - 1]);
if (c[l - 1] != c[r]) {
for (int i = a[r]; i < m; ++i) g[l][r] = max(g[l][r], h[l][r][i] - w * (m - i) + p[0]);
for (int k = l; k + 1 < r; ++k)
if (c[k] == c[r])
for (int i = a[k]; i < m; ++i)
for (int j = max(a[r], m - i); j < m; ++j)
g[l][r] = max(g[l][r], h[l][k][i] + h[k + 1][r][j] + p[i + j - m]);
}
for (int k = r; k <= r; ++k)
if (c[k] != c[r + 1])
f[l][r] = max(f[l][r], g[l][k] + f[k + 1][r]);
}
printf("%lld\n", f[1][n]);
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 6112kb
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: 6144kb
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: 6ms
memory: 6064kb
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: 4ms
memory: 5988kb
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'