QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#808915 | #9873. Last Chance: Threads of Despair | shengZzz | WA | 1ms | 3856kb | C++20 | 1.0kb | 2024-12-11 09:40:16 | 2024-12-11 09:40:17 |
Judging History
answer
#include <bits/stdc++.h>
#define int long long
using namespace std;
void solve(){
int n,m;
cin>>n>>m;
vector<int> h1(n),h2(m);
for(int i=0;i<n;i++) cin>>h1[i];
for(int i=0;i<m;i++) cin>>h2[i];
sort(h1.begin(),h1.end());
sort(h2.begin(),h2.end());
int boom=0,cnt=0,idx=0;
for(int i=0;i<n;i++){
if(h1[i]==1){
boom++;
idx=i;
}
else cnt++;
}
if(h1[0]==1) cnt+=1,boom-=1;
for(int i=0;i<m;i++){
while(idx<n&&h1[idx]-1<=boom){
idx++;
boom++;
}
if(h2[i]-boom>cnt){
cout<<"NO"<<"\n";
return;
}
else{
cnt-=h2[i]-boom;
boom++;
}
}
cout<<"YES"<<"\n";
}
signed main(){
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int T=1;
cin>>T;
while(T--){
solve();
}
return 0;
}
/*
3
3 2
1 1 4
2 6
3 2
1 1 4
2 7
2 1
100 100
2
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3856kb
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: 3448kb
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: 3548kb
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: 3556kb
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: 3852kb
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: 3656kb
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 YES 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 YES NO YES YES YES YES NO NO NO NO NO NO YES YES YES YES YES YES YES YES YES YE...
result:
wrong answer expected NO, found YES [14th token]