QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#646417#5303. No Bug No Gamesw7777Compile Error//C++14894b2024-10-16 22:56:002024-10-16 22:56:00

Judging History

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

  • [2024-10-16 22:56:00]
  • 评测
  • [2024-10-16 22:56:00]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

#define int long long
using i32 = int32_t;
using vi = vector<int>;
const int inf = 1e18;

i32 main() {
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int n, m, sum = 0;
    cin >> n >> m;
    vector f(m + 1, vi(2, -inf));
    f[0][0] = 0;
    for (int i = 1, p; i <= n; i++) {
        cin >> p, sum = min(sum + p, m);
        vi w(p + 1);
        for (int j = 1; j <= p; j++) cin >> w[j];
        for (int j = m; j >= 0; j--) {
            if (j - p >= 0) {
                 f[j][0] = max(f[j][0], f[j - p][0] + w[p]);
                 f[j][1] = max(f[j][1], f[j - p][1] + w[p]);
            }
            for (int k = 1; k < p; k++)
                if (j - k >= 0 and f[j - k][0] > -inf) f[j][1] = max(f[j][1], f[j - k][0] + w[k]);
        }
    }
    cout << max( f[sum][0] , f[sum][1] );
    return 0;
}

詳細信息

answer.code: In function ‘i32 main()’:
answer.code:14:12: error: missing template arguments before ‘f’
   14 |     vector f(m + 1, vi(2, -inf));
      |            ^
answer.code:15:5: error: ‘f’ was not declared in this scope
   15 |     f[0][0] = 0;
      |     ^