QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#360432#1083. Belarusian State UniversitySolitaryDream#WA 7ms15968kbC++171.5kb2024-03-21 19:30:072024-03-21 19:30:08

Judging History

你现在查看的是最新测评结果

  • [2024-03-21 19:30:08]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:15968kb
  • [2024-03-21 19:30:07]
  • 提交

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'