QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#593068#5303. No Bug No GameIron_gainerWA 1ms3808kbC++201.2kb2024-09-27 11:24:212024-09-27 11:24:21

Judging History

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

  • [2024-09-27 11:24:21]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3808kb
  • [2024-09-27 11:24:21]
  • 提交

answer

#include<iostream>
#include<vector>
#include<array>
#include<algorithm>
using namespace std;

typedef long long ll;

void solve() {
    int n, k;
    cin >> n >> k;
    vector<vector<int>> dp(n + 1, vector<int>(k + 1, 0));
    vector<array<int, 11>> v(n + 1);

    for (int i = 1; i <= n; i++) {
        cin >> v[i][0];
        for (int j = 1; j <= v[i][0]; j++) {
            cin >> v[i][j];
        }
    }

    // DP过程
    for (int i = 1; i <= n; i++) {
        for (int j = k; j >= 0; j--) { // 从后向前遍历 j
            // 不升级
            dp[i][j] = dp[i - 1][j];

            // 升级整个物品
            if (j >= v[i][0]) {
                dp[i][j] = max(dp[i][j], dp[i - 1][j - v[i][0]] + v[i][v[i][0]]);
            }

            // 部分升级
            for (int l = 0; l < v[i][0]; l++) {
                if (j >= l) {
                    dp[i][j] = max(dp[i][j], dp[i - 1][j - l] + v[i][l]);
                }
            }
        }
    }

    cout << dp[n][k] << endl;
}

void speed() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main() {
    speed();
    int t = 1; // 假设只运行一次
    while (t--) {
        solve();
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3808kb

input:

4 5
2 1 3
2 1 1
2 3 1
2 1 3

output:

11

result:

wrong answer 1st numbers differ - expected: '9', found: '11'