QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#296842 | #7988. 史莱姆工厂 | Heltion# | WA | 0ms | 3852kb | C++20 | 959b | 2024-01-03 18:07:55 | 2024-01-03 18:07:55 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#include "debug.h"
#else
#define debug(...) 417
#endif
using i64 = int64_t;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
cout << fixed << setprecision(20);
int n, k, w;
cin >> n >> k >> w;
vector<int> m(n), c(n);
for (int& ci : c) { cin >> ci; }
for (int& mi : m) { cin >> mi; }
vector<int> p(2 * k - 1);
for (int i = k; i <= 2 * k - 2; i += 1) { cin >> p[i]; }
vector f(n, vector<i64>(n, numeric_limits<i64>::min()));
for (int j = 0; j < n; j += 1) {
for (int i = j; i >= 0; i -= 1) {
if (i == j) {
f[i][j] = p[k] - w * (k - m[i]);
} else if (c[i] == c[j]) {
f[i][j] = p[m[i] + m[j]] + (i + 1 == j ? 0 : f[i + 1][j - 1]);
}
for (int k = i; k < j; k += 1) {
f[i][j] = max(f[i][j], f[i][k] + f[k + 1][j]);
}
debug(i, j, f[i][j]);
}
}
cout << f[0][n - 1];
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3852kb
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: 3832kb
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'