QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#749841 | #7988. 史莱姆工厂 | lalaouye | WA | 161ms | 24516kb | C++14 | 2.1kb | 2024-11-15 10:48:54 | 2024-11-15 10:48:56 |
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, 0, n + 1) rep (j, 0, n + 1) {
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 + 1) f[i][i - 1] = 0;
rep (len, 1, n) {
rep (l, 1, n - len + 1) {
int r = l + len - 1;
if (c[r] != c[l - 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) {
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<<g[1][n][]
cout << f[1][n];
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5652kb
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: 5812kb
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: 161ms
memory: 24516kb
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: 131ms
memory: 24348kb
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'