QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#810240 | #9873. Last Chance: Threads of Despair | YUKII | WA | 0ms | 3772kb | C++14 | 2.0kb | 2024-12-11 20:37:51 | 2024-12-11 20:37:52 |
Judging History
answer
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = unsigned long long;
int main() {
char const* yes = "Yes", * no = "No";
int n, size1, size2, temp;
cin >> n;
while (n--) {
cin >> size1 >> size2;
vector<int> vec1, vec2;
for (int i = 0; i < size1; ++i) {
cin >> temp;
vec1.push_back(temp);
}
for (int i = 0; i < size2; ++i) {
cin >> temp;
vec2.push_back(temp);
}
sort(vec1.begin(), vec1.end());
sort(vec2.begin(), vec2.end());
bool vec1Has1 = false;
int idx1 = 0, idx2 = 0;
int hurt = 0, deadline = 1;
// 我方有生命值为 1 的随从,则引爆需求为 1 次攻击
for (int i = 1; i <= n; ++i) {
if (vec1[i] == 1) {
if (vec1Has1) {
continue;
}
vec1Has1 = true;
++idx1;
}
--vec1[i], ++hurt;
}
// 如果我方没有生命值为 1 的随从,引爆需求为杀死地方生命值最小的随从
if(!vec1Has1){
if (hurt < vec2[idx2]) {
cout << no << endl;
continue;
} else {
hurt -= vec2[idx2++];
}
}
while (idx2 < size2) {
while(idx1 < size1 && vec1[idx1] <= deadline){
++idx1, ++deadline;
}
if (vec2[idx2] <= deadline) {
++deadline;
} else {
if (vec2[idx2] <= deadline + hurt) {
hurt -= (vec2[idx2] - deadline), ++deadline;
} else {
break;
}
}
++idx2;
}
if (idx2 == size2) {
cout << yes << endl;
} else {
cout << no << endl;
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3772kb
input:
3 3 2 1 1 4 2 6 3 2 1 1 4 2 7 2 1 100 100 2
output:
Yes No No
result:
wrong answer expected YES, found NO [3rd token]