QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#762218#8225. 最小值之和rizynvu0 1ms5944kbC++141.2kb2024-11-19 14:11:452024-11-19 14:11:47

Judging History

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

  • [2024-11-19 14:11:47]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:5944kb
  • [2024-11-19 14:11:45]
  • 提交

answer

#include<bits/stdc++.h>
constexpr int maxn = 50 + 5, maxm = maxn * maxn;
int n, m;
int a[maxn], b[maxn];
bool f[maxn][maxn][maxm];
void dfs(int l, int r, int val) {
   if (l == r) return ;
   for (int c = 0; ; c++, val += r - l) {
      for (int p = l; p < r; p++) {
         if (f[l][p][val] && f[p + 1][r][val]) {
            dfs(l, p, val), dfs(p + 1, r, val);
            b[l] += c, b[r] -= c;
            return ;
         }
      }
   }
}
int main() {
   scanf("%d", &n), m = (n - 1) * 50;
   for (int i = 1; i <= n; i++) {
      scanf("%d", &a[i]);
      if (a[i] > m) {
         return puts("No"), 0;
      }
      f[i][i][a[i]] = 1;
   }
   for (int len = 2; len <= n; len++) {
      for (int l = 1, r = len; r <= n; l++, r++) {
         for (int p = l; p < r; p++) {
            for (int val = 1; val <= m; val++) {
               f[l][r][val] |= f[l][p][val] & f[p + 1][r][val];
            }
         }
         for (int val = m; ~ val; val--) {
            f[l][r][val] |= f[l][r][val + len - 1];
         }
      }
   }
   if (! f[1][n][0]) {
      return puts("No"), 0;
   }
   puts("Yes");
   dfs(1, n, 0);
   for (int i = 1; i < n; i++) {
      printf("%d ", b[i] += b[i - 1]);
   }
   return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 11
Accepted
time: 0ms
memory: 5864kb

input:

5
14 14 12 13 13

output:

Yes
14 0 6 7 

result:

ok The answer is correct.

Test #2:

score: 11
Accepted
time: 0ms
memory: 3876kb

input:

5
4 4 7 7 4

output:

Yes
4 0 5 2 

result:

ok The answer is correct.

Test #3:

score: 11
Accepted
time: 0ms
memory: 5944kb

input:

5
4 13 14 14 13

output:

Yes
1 4 5 4 

result:

ok The answer is correct.

Test #4:

score: 11
Accepted
time: 0ms
memory: 4004kb

input:

5
11 11 10 5 5

output:

Yes
6 5 0 5 

result:

ok The answer is correct.

Test #5:

score: 11
Accepted
time: 0ms
memory: 4000kb

input:

5
10 10 10 4 4

output:

Yes
5 5 0 4 

result:

ok The answer is correct.

Test #6:

score: 11
Accepted
time: 1ms
memory: 5908kb

input:

5
20 20 17 7 4

output:

Yes
10 7 2 1 

result:

ok The answer is correct.

Test #7:

score: 11
Accepted
time: 0ms
memory: 3884kb

input:

5
12 12 16 19 19

output:

Yes
12 0 8 11 

result:

ok The answer is correct.

Test #8:

score: 0
Wrong Answer
time: 0ms
memory: 3900kb

input:

5
2 2 6 11 11

output:

No

result:

wrong answer Line 1 expected 

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%

Subtask #5:

score: 0
Skipped

Dependency #1:

0%

Subtask #6:

score: 0
Skipped

Dependency #1:

0%