QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#360432 | #1083. Belarusian State University | SolitaryDream# | WA | 7ms | 15968kb | C++17 | 1.5kb | 2024-03-21 19:30:07 | 2024-03-21 19:30:08 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 72;
const int M = 305;
int n, a[N];
int f[N][N][M];
int g[N][N][M];
inline void UpdMin(int &x, int y) {
x = min(x, y);
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for (int i = 1; i <= n; ++i) {
cin >> a[i];
}
memset(f, 0x3f, sizeof f);
memset(g, 0x3f, sizeof g);
for (int i = n; i; --i) {
g[i][i][a[i] / 2] = a[i];
for (int j = i; j <= n; ++j)
for (int k = a[j] / 2; k < M; ++k) {
UpdMin(f[i][j][k], g[i][j][k]);
for (int ni = i; ni < j; ++ni)
for (int nk = a[ni] / 2; nk < k; ++nk)
UpdMin(f[i][j][k], f[i][ni][nk] + f[ni + 1][j][k - nk]);
if (j + 1 <= n) {
// update g[i][j + 1][*]
if (k >= a[j + 1]) UpdMin(g[i][j + 1][k / 2], g[i][j][k]);
else UpdMin(g[i][j + 1][a[j + 1] / 2], f[i][j][k] + a[j + 1] - k);
for (int ni = i; ni + 1 <= j; ++ni)
for (int nk = 0; nk < a[j + 1]; ++nk)
if (nk + k >= a[j + 1])
UpdMin(g[i][j + 1][(nk + k) / 2], g[i][ni][k] + f[ni + 1][j][nk]);
}
}
}
for (int i = 1; i <= n; ++i) {
cout << *min_element(f[1][i], f[1][i] + M) << ' ';
}
cout << endl;
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 7ms
memory: 15968kb
input:
3 0111 0110 0001 0 0 0 0 0 1 0 0 0 0 0 0 0 0 1 0
output:
111 166 166
result:
wrong answer 1st numbers differ - expected: '0', found: '111'