QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#90035 | #5481. Beast Bullies | EasyJudge | WA | 137ms | 5156kb | C++23 | 1.1kb | 2023-03-22 02:46:53 | 2023-03-22 02:46:54 |
Judging History
answer
#include <iostream>
#include <queue>
using namespace std;
int main() {
int n;
cin >> n;
// create a priority queue to store the strengths of the animals
priority_queue<int> pq;
// read in the strengths and add them to the priority queue
for (int i = 0; i < n; i++) {
int strength;
cin >> strength;
pq.push(strength);
}
// keep track of the sum of the strengths of the animals
int sum = 0;
for (int i = 0; i < n; i++) {
// get the strength of the weakest animal
int weakest = pq.top();
pq.pop();
// calculate the sum of the strengths of the attackers and defenders
int attackers = sum - weakest;
int defenders = weakest;
// check if the weakest animal should leave
if (attackers > defenders) {
// the weakest animal should leave
break;
}
// the weakest animal should stay
sum += weakest;
}
// output the number of animals remaining
cout << pq.size() << endl;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 137ms
memory: 5156kb
input:
500000 976631732 51389671 729809897 630844317 294721017 903231515 477913449 871071076 636104080 345822085 97441187 499323378 522845426 310022664 199310190 776622973 602672555 646874222 214723272 285341530 962727359 681361226 47426538 272153520 693133904 542337627 556307610 325596239 95738088 5495543...
output:
499997
result:
wrong answer 1st lines differ - expected: '155101', found: '499997'