QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#293755 | #7988. 史莱姆工厂 | lprdsb | WA | 16ms | 294732kb | C++14 | 2.3kb | 2023-12-29 18:13:44 | 2023-12-29 18:13:44 |
Judging History
answer
#include<bits/stdc++.h>
#define For(i, a, b) for(int i = (a), en = (b); i <= en; ++i)
#define Rof(i, a, b) for(int i = (a), en = (b); i >= en; --i)
#define Tra(u, i) for(int i = hd[u]; ~i; i = e[i].net)
#define cst const
#define LL long long
#define DD double
#define LD long double
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define inf 0x3f3f3f3f
#define Inf 0x3f3f3f3f3f3f3f3f
#define eps 1e-12
using namespace std;
#define maxn 150
int n, k, w, C[maxn + 5], M[maxn + 5], P[maxn + 5];
LL f[maxn + 5][maxn + 5][maxn + 5][10];
template <class T>
void read(T& x) {
char ch;
bool ok;
for(ok = 0, ch = getchar(); !isdigit(ch); ch = getchar()) if(ch == '-') ok = 1;
for(x = 0; isdigit(ch); x = x * 10 + ch - '0', ch = getchar());
if(ok) x = -x;
}
void chkmx(LL &x, LL y) { if(x < y) x = y; }
int main() {
// freopen("in.txt", "r", stdin);
memset(f, -inf, sizeof f);
// cout << f[0][0][0][0] << endl;
read(n); read(k); read(w);
For(i, 1, n) read(C[i]);
For(i, 1, n) read(M[i]);
For(i, k, 2 * k - 2) read(P[i]);
Rof(l, n, 1) {
f[l][l][C[l]][M[l]] = 0;
For(i, 2, k - 1) chkmx(f[l][l][1][i], f[l][l][1][i - 1] - w);
chkmx(f[l][l][0][0], f[l][l][C[l]][k - 1] - w + P[k]);
For(r, l + 1, n) {
For(i, l, r - 1) if(C[i] != C[l - 1] || C[i] != C[r + 1]) {
chkmx(f[l][r][0][0], f[l][i][0][0] + f[i + 1][r][0][0]);
For(o1, 1, k - 1) {
chkmx(f[l][r][C[i]][o1], f[l][i][C[i]][o1] + f[i + 1][r][0][0]);
chkmx(f[l][r][C[i]][o1], f[l][i][0][0] + f[i + 1][r][C[i]][o1]);
For(o2, 1, k - 1) {
if(o1 + o2 < k) chkmx(f[l][r][C[i]][o1 + o2], f[l][i][C[i]][o1] + f[i + 1][r][C[i]][o2]);
else chkmx(f[l][r][0][0], f[l][i][C[i]][o1] + f[i + 1][r][C[i]][o2] + P[o1 + o2]);
}
}
}
chkmx(f[l][r][C[r]][M[r]], f[l][r - 1][0][0]);
For(c, 1, n) {
For(i, 2, k - 1) chkmx(f[l][r][c][i], f[l][r][c][i - 1] - w);
chkmx(f[l][r][0][0], f[l][r][c][k - 1] - w + P[k]);
}
}
}
// cout << f[2][3][2][3] << endl;
printf("%lld\n", f[1][n][0][0]);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 16ms
memory: 294680kb
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: 15ms
memory: 294732kb
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'