QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#749819 | #7988. 史莱姆工厂 | lalaouye | WA | 1ms | 7792kb | C++14 | 2.1kb | 2024-11-15 10:32:28 | 2024-11-15 10:32:30 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
#define rep(i, l, r) for (int i (l); i <= r; ++ i)
#define rrp(i, l, r) for (int i (r); i >= l; -- i)
#define pii pair <int, int>
#define eb emplace_back
#define ls p << 1
#define rs ls | 1
#define inf 1000000000000
using namespace std;
constexpr int N = 150 + 5, K = 10;
typedef unsigned long long ull;
typedef long long ll;
inline ll rd () {
ll x = 0, f = 1;
char ch = getchar ();
while (! isdigit (ch)) {
if (ch == '-') f = -1;
ch = getchar ();
}
while (isdigit (ch)) {
x = (x << 1) + (x << 3) + ch - 48;
ch = getchar ();
}
return x * f;
}
int f[N][N], g1[N][N][K], g2[N][N][K][K];
int n, m, w;
int c[N], G[N];
int p[K << 1];
int val (int s) {
if (s < m) return p[m] - (m - s) * w;
return p[s];
}
signed main () {
// freopen ("1.in", "r", stdin);
// freopen ("1.out", "w", stdout);
n = rd (), m = rd (), w = rd ();
rep (i, 1, n) c[i] = rd ();
rep (i, 1, n) G[i] = rd ();
rep (i, m, m * 2 - 2) p[i] = rd ();
rep (i, 1, n) rep (j, i, n) {
f[i][j] = -inf;
rep (k, 0, m - 1) {
g1[i][j][k] = -inf;
rep (l, 0, m - 1) {
g2[i][j][k][l] = -inf;
}
}
}
rep (i, 1, n) f[i][i - 1] = 0;
rep (len, 1, n) {
rep (l, 1, n - len + 1) {
int r = l + len - 1;
f[l][r] = f[l][r - 1] + val (G[r]);
g1[l][r][G[r]] = f[l][r - 1];
rep (s1, 0, m - 1) {
rep (k, l, r - 1) {
if (c[k] == c[r])
g2[l][r][s1][G[r]] = max (g2[l][r][s1][G[r]], g1[l][k][s1] + f[k + 1][r - 1]);
if (s1 >= G[r] && c[k] == c[r]) g1[l][r][s1] = max (g1[l][r][s1], g1[l][k][s1 - G[r]] + f[k + 1][r - 1]);
rep (s2, 0, m - 1) {
if (c[k] != c[l - 1] && c[k] != c[r + 1])
f[l][r] = max (f[l][r], f[k + 1][r] + g2[l][k][s1][s2] + val (s1 + s2));
if (s2 >= G[r] && c[k] == c[r])
g2[l][r][s1][s2] = max (g2[l][r][s1][s2], g2[l][k][s1][s2 - G[r]] + f[k + 1][r - 1]);
}
}
}
}
}
cout << f[1][n];
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5784kb
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: 0ms
memory: 7792kb
input:
5 7 500 2 3 2 3 2 5 6 6 6 4 1000 900 800 400 200 50
output:
1000
result:
wrong answer 1st lines differ - expected: '1400', found: '1000'