QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#808023 | #9873. Last Chance: Threads of Despair | zzfs# | WA | 0ms | 3620kb | C++17 | 1.3kb | 2024-12-10 16:24:19 | 2024-12-10 16:24:20 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
void sol()
{
int n, m;
cin >> n >> m;
// val, type
vector<pair<int, int>> vec;
int can_do = 0;
int one_cnt = 0;
for (int i = 0; i < n; i++)
{
int num;
cin >> num;
if(num > 1)
{
vec.push_back({num - 1, 1});
can_do++;
}
else
{
vec.push_back({num, 1});
one_cnt ++;
}
}
for (int i = 0; i < m; i++)
{
int num;
cin >> num;
vec.push_back({num, 2});
}
sort(vec.begin(), vec.end());
int op = 0;
int other_cnt = 0;
for (int i = 0; i < m + n; i++)
{
if(vec[i].first > max(i, 1))
{
op += vec[i].first - max(i, 1);
if(vec[i].second == 2)
{
other_cnt++;
}
}
if(other_cnt == m) break;
}
if(one_cnt == 0)
{
if(can_do > op)
cout << "Yes\n";
else
cout << "No\n";
}
else
{
if(can_do + 1 >= op)
cout << "Yes\n";
else
cout << "No\n";
}
}
int main()
{
int T;
cin >> T;
while (T--)
{
sol();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
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: 3592kb
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: 3616kb
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: 3508kb
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: -100
Wrong Answer
time: 0ms
memory: 3620kb
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 Yes Yes Yes No Yes No No
result:
wrong answer expected NO, found YES [12th token]