QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#360453#1093. Bookcase Solidity UnitedSolitaryDream#WA 7ms16040kbC++171.6kb2024-03-21 19:47:252024-03-21 19:47:25

Judging History

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

  • [2024-03-21 19:47:25]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:16040kb
  • [2024-03-21 19:47:25]
  • 提交

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], f[i][j][k - 1] + 1);
                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][a[j + 1] / 2], f[i][j][k] + a[j + 1] - k);
                    for (int nk = k + 0; nk <= k + a[j + 1] - 1; ++nk) if (nk >= a[j + 1]) UpdMin(g[i][j + 1][nk / 2], g[i][j][k] + (nk - 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;

}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 16036kb

input:

3
8 1 2

output:

8 8 8 

result:

ok 3 number(s): "8 8 8"

Test #2:

score: 0
Accepted
time: 3ms
memory: 15920kb

input:

5
10 3 3 8 4

output:

10 10 11 17 17 

result:

ok 5 number(s): "10 10 11 17 17"

Test #3:

score: 0
Accepted
time: 0ms
memory: 15964kb

input:

1
1

output:

1 

result:

ok 1 number(s): "1"

Test #4:

score: 0
Accepted
time: 0ms
memory: 15960kb

input:

1
150

output:

150 

result:

ok 1 number(s): "150"

Test #5:

score: 0
Accepted
time: 3ms
memory: 15964kb

input:

2
80 82

output:

80 122 

result:

ok 2 number(s): "80 122"

Test #6:

score: 0
Accepted
time: 6ms
memory: 15964kb

input:

2
4 76

output:

4 78 

result:

ok 2 number(s): "4 78"

Test #7:

score: 0
Accepted
time: 0ms
memory: 15924kb

input:

2
32 124

output:

32 140 

result:

ok 2 number(s): "32 140"

Test #8:

score: 0
Accepted
time: 0ms
memory: 16016kb

input:

2
2 119

output:

2 120 

result:

ok 2 number(s): "2 120"

Test #9:

score: 0
Accepted
time: 0ms
memory: 16008kb

input:

5
4 82 94 39 20

output:

4 84 137 137 137 

result:

ok 5 number(s): "4 84 137 137 137"

Test #10:

score: 0
Accepted
time: 4ms
memory: 15976kb

input:

7
85 49 150 12 50 94 113

output:

85 92 218 218 230 274 337 

result:

ok 7 numbers

Test #11:

score: 0
Accepted
time: 0ms
memory: 15976kb

input:

8
105 33 66 143 120 43 62 47

output:

105 105 138 246 295 295 327 343 

result:

ok 8 numbers

Test #12:

score: 0
Accepted
time: 5ms
memory: 15924kb

input:

9
43 123 72 93 32 65 43 71 81

output:

43 145 156 213 213 248 259 309 355 

result:

ok 9 numbers

Test #13:

score: 0
Accepted
time: 3ms
memory: 16040kb

input:

9
20 77 41 80 120 75 75 69 120

output:

20 87 90 150 230 245 283 315 401 

result:

ok 9 numbers

Test #14:

score: 0
Accepted
time: 3ms
memory: 15980kb

input:

9
148 134 18 2 12 130 107 12 122

output:

148 208 208 208 208 287 329 329 404 

result:

ok 9 numbers

Test #15:

score: 0
Accepted
time: 5ms
memory: 16028kb

input:

9
117 96 145 139 146 36 140 2 12

output:

117 155 252 319 396 396 481 481 481 

result:

ok 9 numbers

Test #16:

score: 0
Accepted
time: 5ms
memory: 16036kb

input:

9
49 95 10 14 38 45 22 141 109

output:

49 120 120 120 139 157 157 279 318 

result:

ok 9 numbers

Test #17:

score: 0
Accepted
time: 7ms
memory: 15904kb

input:

9
27 57 136 48 126 100 54 131 149

output:

27 71 179 179 261 298 302 406 490 

result:

ok 9 numbers

Test #18:

score: 0
Accepted
time: 5ms
memory: 16020kb

input:

9
108 10 9 81 64 110 86 121 47

output:

108 108 108 145 169 247 278 356 356 

result:

ok 9 numbers

Test #19:

score: 0
Accepted
time: 3ms
memory: 15964kb

input:

9
86 114 128 106 2 15 119 64 40

output:

86 157 228 270 270 270 345 350 358 

result:

ok 9 numbers

Test #20:

score: -100
Wrong Answer
time: 4ms
memory: 15980kb

input:

9
56 76 105 140 90 25 1 54 80

output:

56 104 171 259 279 279 279 306 355 

result:

wrong answer 8th numbers differ - expected: '305', found: '306'