QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#184708#1093. Bookcase Solidity UnitedyllcmWA 0ms3820kbC++141.9kb2023-09-21 09:20:012023-09-21 09:20:02

Judging History

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

  • [2023-09-21 09:20:02]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3820kb
  • [2023-09-21 09:20:01]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define FR first
#define SE second
#define il inline
using namespace std;
inline int read() {
  int x = 0; bool op = 0;
  char c = getchar();
  while(!isdigit(c))op |= (c == '-'), c = getchar();
  while(isdigit(c))x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
  return op ? -x : x;
}
il bool chkmin(int &a, int b) {return (b < a ? a = b, true : false);}
const int N = 75;
const int M = 155;
const int INF = 1e9;
int n, sid;
int a[N], f[N][N][M];
void solve() {
  n = read();
  for(int i = 1; i <= n; i++)a[i] = read();
  int mx = 0;
  for(int i = 1; i <= n; i++)mx = max(mx, a[i]);
  for(int i = 1; i <= n; i++) {
    for(int j = i; j <= n; j++) {
      for(int v = 0; v <= mx; v++) {
        f[i][j][v] = INF;
      }
    }
  }
  for(int k = 1; k <= n; k++) {
    for(int i = 1; i + k - 1 <= n; i++) {
      int j = i + k - 1;
      for(int v = 0; v <= mx; v++) {
        for(int l = i; l <= j; l++) {
          for(int t = 0; t <= mx && max(a[l], t) / 2 <= v; t++) {
            int w = max(a[l] - t, 0);
            if(i < l)w += f[i][l - 1][t];
            else w += (t == 0 ? 0 : INF);
            if(l < j)w += f[l + 1][j][t];
            else w += (v - max(a[l], t) / 2 == 0 ? 0 : INF);
            // printf("qwq:%d %d %d %d\n", i, j, v, w);
            chkmin(f[i][j][v], w);
            // chkmin(f[i][j][v], f[i][l - 1][t] + f[l + 1][j][v - max(a[l], t) / 2] + max(a[l] - t, 0));
          }
        }
      }
    }
  }
  for(int i = 1; i <= n; i++) {
    int ans = INF;
    for(int v = 0; v <= mx; v++)chkmin(ans, f[1][i][v]);
    printf("%d ", ans);
  }
  putchar('\n');
  return ;
}
int main() { 
  int test = 1;
  while(test--)solve();
  return 0;
}

詳細信息

Test #1:

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

input:

3
8 1 2

output:

8 8 8 

result:

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

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3788kb

input:

5
10 3 3 8 4

output:

10 10 11 18 18 

result:

wrong answer 4th numbers differ - expected: '17', found: '18'