QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#277802#5303. No Bug No GameqkyWA 28ms3988kbC++17929b2023-12-06 22:57:172023-12-06 22:57:18

Judging History

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

  • [2023-12-06 22:57:18]
  • 评测
  • 测评结果:WA
  • 用时:28ms
  • 内存:3988kb
  • [2023-12-06 22:57:17]
  • 提交

answer

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Item {
    int power;
    vector<int> bonus;
};

bool compare(const Item& a, const Item& b) {
    return a.power > b.power;
}

int main() {
    int n, k;
    cin >> n >> k;

    vector<Item> items(n);
    for (int i = 0; i < n; i++) {
        cin >> items[i].power;
        items[i].bonus.resize(items[i].power);
        for (int j = 0; j < items[i].power; j++) {
            cin >> items[i].bonus[j];
        }
    }

    sort(items.begin(), items.end(), compare);

    vector<int> dp(k + 1, 0);
    for (int i = 0; i < n; i++) {
        for (int j = k; j >= items[i].power; j--) {
            for (int l = 0; l < items[i].power; l++) {
                dp[j] = max(dp[j], dp[j - items[i].power + l] + items[i].bonus[l]);
            }
        }
    }

    cout << dp[k] << endl;

    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

9

result:

ok 1 number(s): "9"

Test #2:

score: -100
Wrong Answer
time: 28ms
memory: 3988kb

input:

3000 3000
10 70562 30723 79371 82224 63977 3362 26909 96449 48163 66159
4 18007 33590 80674 91139
4 10304 31694 70745 50656
10 63090 17226 13187 73881 38137 15237 55750 82751 75854 39658
8 95640 66120 87735 36388 44046 92415 6952 94772
9 60565 27904 98726 87052 35768 25453 14563 34273 92501
10 66332...

output:

170189795

result:

wrong answer 1st numbers differ - expected: '68279788', found: '170189795'