QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#277795 | #5303. No Bug No Game | qky | WA | 2ms | 3756kb | C++17 | 1.2kb | 2023-12-06 22:53:50 | 2023-12-06 22:53:55 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
struct Item {
int basePower;
vector<int> bonusPower;
};
bool compareItems(const Item& item1, const Item& item2) {
return item1.bonusPower.back() > item2.bonusPower.back();
}
int main() {
int n, k;
cin >> n >> k;
vector<Item> items(n);
for (int i = 0; i < n; i++) {
int p;
cin >> p;
items[i].basePower = p;
items[i].bonusPower.resize(p);
for (int j = 0; j < p; j++) {
cin >> items[i].bonusPower[j];
}
sort(items[i].bonusPower.begin(), items[i].bonusPower.end());
}
sort(items.begin(), items.end(), compareItems);
int totalBonusPower = 0;
int sum = 0;
for (int i = 0; i < n; i++) {
if (sum + items[i].basePower <= k) {
totalBonusPower += items[i].bonusPower.back();
sum += items[i].basePower;
} else if (sum < k) {
int remainingPower = k - sum;
totalBonusPower += items[i].bonusPower[items[i].basePower - remainingPower];
sum = k;
} else {
break;
}
}
cout << totalBonusPower << endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3496kb
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: 2ms
memory: 3756kb
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:
42494642
result:
wrong answer 1st numbers differ - expected: '68279788', found: '42494642'