QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#810156 | #9873. Last Chance: Threads of Despair | YUKII | WA | 1ms | 3800kb | C++14 | 2.2kb | 2024-12-11 20:08:04 | 2024-12-11 20:08:05 |
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());
int hurt = size1 + 1;
int deadline = 0;
int idx1 = 0, idx2 = 0;
while (idx1 < size1 && vec1[idx1] == 1) {
--hurt, ++deadline, ++idx1;
}
while (idx1 < size1 && vec1[idx1] <= deadline) {
++idx1, ++deadline;
}
while (idx2 < size2 && vec2[idx2] <= deadline) {
++idx2, ++deadline;
}
if (idx2 == size2) {
cout << yes << endl;
continue;;
}
if (idx1) {
--vec2[idx2];
}
int curIdx1 = idx1;
bool changed = true;
while (changed) {
changed = false;
while (idx1 < size1 && vec1[idx1] <= deadline) {
changed = true;
++idx1, ++deadline;
}
while (idx2 < size2 && vec2[idx2] <= deadline) {
changed = true;
++idx2, ++deadline;
}
if (idx2 < size2 && curIdx1 < size1) {
changed = true;
if (vec1[curIdx1] - 1 <= deadline) {
while (idx2 < size2 && curIdx1 < size1 && vec2[idx2] <= deadline + 1) {
++idx2, ++deadline;
}
}
if (idx2 < size2 && curIdx1 < size1) {
--vec1[curIdx1], --vec2[idx2], ++curIdx1;
}
}
}
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: 100
Accepted
time: 0ms
memory: 3764kb
input:
3 3 2 1 1 4 2 6 3 2 1 1 4 2 7 2 1 100 100 2
output:
Yes No Yes
result:
ok 3 token(s): yes count is 2, no count is 1
Test #2:
score: 0
Accepted
time: 0ms
memory: 3800kb
input:
3 7 1 1 1 1 1 1 1 1 9 5 2 3 4 5 6 7 1 6 5 3 3 4 5 6 7 1 5 7
output:
No No Yes
result:
ok 3 token(s): yes count is 1, no count is 2
Test #3:
score: 0
Accepted
time: 0ms
memory: 3588kb
input:
4 1 1 1 1 1 1 1 2 1 1 2 1 1 1 2 2
output:
Yes Yes Yes No
result:
ok 4 token(s): yes count is 3, no count is 1
Test #4:
score: 0
Accepted
time: 0ms
memory: 3796kb
input:
18 1 2 1 1 1 1 2 1 2 1 1 2 1 1 3 1 2 1 2 2 1 2 1 3 2 1 2 1 3 3 1 2 2 1 1 1 2 2 1 2 1 2 2 1 3 1 2 2 2 2 1 2 2 2 3 1 2 2 3 3 1 2 3 1 1 1 2 3 1 2 1 2 3 1 3 1 2 3 2 2 1 2 3 3 2 1 2 3 3 3
output:
Yes Yes Yes Yes No No Yes Yes No No No No Yes No No No No No
result:
ok 18 token(s): yes count is 7, no count is 11
Test #5:
score: 0
Accepted
time: 0ms
memory: 3528kb
input:
18 2 1 1 1 1 2 1 1 1 2 2 1 1 1 3 2 1 1 2 1 2 1 2 1 2 2 1 2 1 3 2 1 1 3 1 2 1 1 3 2 2 1 3 1 3 2 1 2 2 1 2 1 2 2 2 2 1 2 2 3 2 1 2 3 1 2 1 3 2 2 2 1 2 3 3 2 1 3 3 1 2 1 3 3 2 2 1 3 3 3
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes No Yes Yes No
result:
ok 18 token(s): yes count is 15, no count is 3
Test #6:
score: -100
Wrong Answer
time: 1ms
memory: 3524kb
input:
525 2 3 1 1 1 1 1 2 3 1 1 1 2 1 2 3 1 1 1 3 1 2 3 1 1 1 4 1 2 3 1 1 5 1 1 2 3 1 1 2 2 1 2 3 1 1 3 1 2 2 3 1 1 1 2 4 2 3 1 1 2 1 5 2 3 1 1 3 3 1 2 3 1 1 4 3 1 2 3 1 1 3 5 1 2 3 1 1 4 4 1 2 3 1 1 4 5 1 2 3 1 1 1 5 5 2 3 1 1 2 2 2 2 3 1 1 2 3 2 2 3 1 1 2 2 4 2 3 1 1 2 5 2 2 3 1 1 3 2 3 2 3 1 1 3 2 4 2 ...
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No No Yes Yes Yes Yes Yes Yes Yes Yes No No Yes Yes No No No No No No No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No No Yes Yes Yes Yes No No No No No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes ...
result:
wrong answer expected NO, found YES [50th token]