QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#808206 | #9873. Last Chance: Threads of Despair | ucup-team4975# | WA | 0ms | 3852kb | C++23 | 1.3kb | 2024-12-10 18:00:36 | 2024-12-10 18:00:38 |
Judging History
answer
#include <bits/stdc++.h>
#define fir first
#define sec second
#define el '\n'
#define debug(x) cout << #x << ":: " << x << endl;
#define int long long
#define FINISH cout << "FINISH" << endl;
#define debugv(x) cout << #x << ":: ";\
for (auto i : x) \
cout << i << " "; \
cout << endl
using namespace std;
using ll = long long;
using ld = long double;
using PII = pair<int, int>;
const int inf = 0x3f3f3f3f;
const int N = 200020;
const ld PI = 3.14159265358979323846;
void solve()
{
int n,m;
cin>>n>>m;
vector<int> a(n,0),b(m,0);
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<m;i++)cin>>b[i];
sort(a.begin(),a.end());
sort(b.begin(),b.end());
int cnt=n;
set<int> s;
for(int i=0;i<n;i++){
if(a[i]==1)cnt--;
s.insert(a[i]);
}
if(s.count(1))cnt++;
s.clear();
int bk=0,q=0;
for(int i=0;i<n;i++){
while(a[i]-1<bk)a[i]++;
s.insert(a[i]-1);
while(s.count(bk))bk++;
}
while(q<m&&cnt>=0){
while(s.count(bk))bk++;
while(b[q]>bk&&cnt>0){
b[q]--;
cnt--;
}
while(b[q]<bk)b[q]++;
s.insert(bk);
q++;
}
if(b[m-1]<=bk)cout<<"Yes\n";
else cout<<"No\n";
return;
}
signed main()
{
ios:: sync_with_stdio("false");
cin.tie(nullptr);
cout.tie(nullptr);
int T= 1;
cin >> T;
while (T--) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3592kb
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: 3852kb
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: 3772kb
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: -100
Wrong Answer
time: 0ms
memory: 3656kb
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 Yes No No Yes No No No No No
result:
wrong answer expected NO, found YES [10th token]