QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#821109 | #9873. Last Chance: Threads of Despair | vwxyz | Compile Error | / | / | Python3 | 1.3kb | 2024-12-19 13:19:08 | 2024-12-19 13:19:12 |
Judging History
This is the latest submission verdict.
- [2024-12-19 13:19:12]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-12-19 13:19:08]
- Submitted
answer
#include <iostream>
#include <vector>
#include <algorithm>
bool solve(int N, int M, std::vector<int>& A, std::vector<int>& B) {
std::sort(A.begin(), A.end());
std::sort(B.begin(), B.end());
int cnt = 0;
// Adjust A and calculate the count of adjustments
for (int i = 0; i < N; ++i) {
if (A[i] > 1 || (i == 0 && A[i] == 1)) {
cnt++;
A[i]--;
}
}
int a = 0; // Index pointer for A
for (int b = 0; b < M; ++b) {
// Move pointer 'a' while A[a] <= a + b
while (a < N && A[a] <= a + b) {
a++;
}
// Try to reduce B[b] using the available count
while (cnt > 0 && a + b < B[b]) {
B[b]--;
cnt--;
}
// If B[b] cannot be satisfied, return false
if (a + b < B[b]) {
return false;
}
}
return true;
}
int main() {
int T;
std::cin >> T;
while (T--) {
int N, M;
std::cin >> N >> M;
std::vector<int> A(N), B(M);
for (int i = 0; i < N; ++i) std::cin >> A[i];
for (int i = 0; i < M; ++i) std::cin >> B[i];
if (solve(N, M, A, B)) {
std::cout << "Yes" << std::endl;
} else {
std::cout << "No" << std::endl;
}
}
return 0;
}
Details
File "answer.code", line 5 bool solve(int N, int M, std::vector<int>& A, std::vector<int>& B) { ^^^^^ SyntaxError: invalid syntax