QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#818884 | #9873. Last Chance: Threads of Despair | icealsoheat | WA | 44ms | 5876kb | C++17 | 2.5kb | 2024-12-18 10:32:55 | 2024-12-18 10:32:57 |
Judging History
answer
#pragma GCC optimize(3) //O2优化开启
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
const int mod=998244353;
const int MX=0x3f3f3f3f3f3f3f3f;
int n,m;
int a[500005];
int b[500005];
void icealsoheat(){
cin>>n>>m;
for(int i=1;i<=n;i++)cin>>a[i];
for(int i=1;i<=m;i++)cin>>b[i];
int cnt=0;
sort(a+1,a+1+n);
sort(b+1,b+1+m);
int id;
id=1;
int op=0;
for(int i=n;i>=1;i--){
op++;
if(a[i]==1)break;
}
queue<int>q;
while(id<=n&&cnt>=a[id]-1){
cnt++;
id++;
}
for(int i=1;i<=m;i++){
assert(op>=0);
if(op+cnt<b[i]){
puts("No");
return;
}
op+=q.size();
if(b[i]>cnt-q.size()){
op-=b[i]-cnt+q.size();
}
int g=cnt+1;
cnt++;
while(id<=n&&cnt>=a[id]-1){
cnt++;
id++;
}
if(b[i]>cnt)q.push(b[i]);
while(q.size()){
if(q.front()<cnt){
int need=q.front()-g;
need=max(0ll,need);
op+=min(need,cnt-q.front());
q.pop();
}
else{
break;
}
}
}
puts("Yes");
}
signed main(){
ios::sync_with_stdio(false); //int128不能用快读!!!!!!
cin.tie();
cout.tie();
int _yq;
_yq=1;
cin>>_yq;
while(_yq--){
icealsoheat();
}
}
//
//⠀⠀⠀ ⠀⢸⣿⣿⣿⠀⣼⣿⣿⣦⡀
//⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠀⠀⠀ ⠀⢸⣿⣿⡟⢰⣿⣿⣿⠟⠁
//⠀⠀⠀⠀⠀⠀⠀⢰⣿⠿⢿⣦⣀⠀⠘⠛⠛⠃⠸⠿⠟⣫⣴⣶⣾⡆
//⠀⠀⠀⠀⠀⠀⠀⠸⣿⡀⠀⠉⢿⣦⡀⠀⠀⠀⠀⠀⠀ ⠛⠿⠿⣿⠃
//⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣦⠀⠀⠹⣿⣶⡾⠛⠛⢷⣦⣄⠀
//⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣧⠀⠀⠈⠉⣀⡀⠀ ⠀⠙⢿⡇
//⠀⠀⠀⠀⠀⠀⢀⣠⣴⡿⠟⠋⠀⠀⢠⣾⠟⠃⠀⠀⠀⢸⣿⡆
//⠀⠀⠀⢀⣠⣶⡿⠛⠉⠀⠀⠀⠀⠀⣾⡇⠀⠀⠀⠀⠀⢸⣿⠇
//⢀⣠⣾⠿⠛⠁⠀⠀⠀⠀⠀⠀⠀⢀⣼⣧⣀⠀⠀⠀⢀⣼⠇
//⠈⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⢀⣴⡿⠋⠙⠛⠛⠛⠛⠛⠁
//⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣾⡿⠋⠀
//⠀⠀⠀⠀⠀⠀⠀⠀⢾⠿⠋⠀
//
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5684kb
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: 1ms
memory: 5676kb
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: 1ms
memory: 5652kb
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: 1ms
memory: 5544kb
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: 5876kb
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: 0
Accepted
time: 1ms
memory: 5592kb
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 No 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 Yes ...
result:
ok 525 token(s): yes count is 202, no count is 323
Test #7:
score: 0
Accepted
time: 0ms
memory: 5648kb
input:
525 3 2 1 1 1 1 1 3 2 1 1 1 2 1 3 2 1 1 1 3 1 3 2 1 1 1 1 4 3 2 1 1 1 1 5 3 2 1 1 1 2 2 3 2 1 1 1 2 3 3 2 1 1 1 4 2 3 2 1 1 1 2 5 3 2 1 1 1 3 3 3 2 1 1 1 4 3 3 2 1 1 1 5 3 3 2 1 1 1 4 4 3 2 1 1 1 5 4 3 2 1 1 1 5 5 3 2 1 1 2 1 1 3 2 2 1 1 2 1 3 2 2 1 1 1 3 3 2 1 2 1 1 4 3 2 1 1 2 5 1 3 2 1 1 2 2 2 3 ...
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes No No No No Yes Yes Ye...
result:
ok 525 token(s): yes count is 317, no count is 208
Test #8:
score: 0
Accepted
time: 0ms
memory: 5612kb
input:
3136 3 3 1 1 1 1 1 1 3 3 1 1 1 2 1 1 3 3 1 1 1 3 1 1 3 3 1 1 1 1 1 4 3 3 1 1 1 5 1 1 3 3 1 1 1 1 1 6 3 3 1 1 1 2 1 2 3 3 1 1 1 2 1 3 3 3 1 1 1 1 4 2 3 3 1 1 1 2 5 1 3 3 1 1 1 1 6 2 3 3 1 1 1 3 3 1 3 3 1 1 1 4 1 3 3 3 1 1 1 1 5 3 3 3 1 1 1 1 3 6 3 3 1 1 1 4 1 4 3 3 1 1 1 4 1 5 3 3 1 1 1 4 1 6 3 3 1 1...
output:
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 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 No Yes Yes...
result:
ok 3136 token(s): yes count is 1458, no count is 1678
Test #9:
score: 0
Accepted
time: 8ms
memory: 5672kb
input:
17640 3 4 1 1 1 1 1 1 1 3 4 1 1 1 2 1 1 1 3 4 1 1 1 1 1 1 3 3 4 1 1 1 1 1 1 4 3 4 1 1 1 5 1 1 1 3 4 1 1 1 1 6 1 1 3 4 1 1 1 7 1 1 1 3 4 1 1 1 1 1 2 2 3 4 1 1 1 1 2 3 1 3 4 1 1 1 1 4 1 2 3 4 1 1 1 5 1 2 1 3 4 1 1 1 2 1 1 6 3 4 1 1 1 7 1 1 2 3 4 1 1 1 3 3 1 1 3 4 1 1 1 4 1 3 1 3 4 1 1 1 1 1 3 5 3 4 1 ...
output:
Yes Yes 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 No 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 Yes Yes Yes Yes Yes Yes Yes Yes Yes No No Yes Yes Yes Yes Yes Yes Yes Yes No No Yes Yes No N...
result:
ok 17640 token(s): yes count is 6647, no count is 10993
Test #10:
score: 0
Accepted
time: 8ms
memory: 5588kb
input:
17640 4 3 1 1 1 1 1 1 1 4 3 1 1 1 1 1 2 1 4 3 1 1 1 1 3 1 1 4 3 1 1 1 1 1 1 4 4 3 1 1 1 1 1 5 1 4 3 1 1 1 1 6 1 1 4 3 1 1 1 1 1 1 7 4 3 1 1 1 1 1 2 2 4 3 1 1 1 1 3 1 2 4 3 1 1 1 1 2 4 1 4 3 1 1 1 1 1 2 5 4 3 1 1 1 1 1 2 6 4 3 1 1 1 1 7 2 1 4 3 1 1 1 1 1 3 3 4 3 1 1 1 1 4 1 3 4 3 1 1 1 1 5 3 1 4 3 1 ...
output:
Yes Yes 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 No 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 Yes Yes Yes Yes Yes Yes Yes Yes Yes No No Yes Yes Yes Yes Yes Yes Yes Yes No No Yes Yes No N...
result:
ok 17640 token(s): yes count is 8926, no count is 8714
Test #11:
score: 0
Accepted
time: 44ms
memory: 5668kb
input:
95040 3 5 1 1 1 1 1 1 1 1 3 5 1 1 1 2 1 1 1 1 3 5 1 1 1 1 3 1 1 1 3 5 1 1 1 1 1 4 1 1 3 5 1 1 1 1 5 1 1 1 3 5 1 1 1 1 1 6 1 1 3 5 1 1 1 7 1 1 1 1 3 5 1 1 1 1 1 1 8 1 3 5 1 1 1 2 1 2 1 1 3 5 1 1 1 1 1 2 1 3 3 5 1 1 1 1 4 2 1 1 3 5 1 1 1 2 5 1 1 1 3 5 1 1 1 6 1 2 1 1 3 5 1 1 1 1 7 2 1 1 3 5 1 1 1 1 8 ...
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes 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 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 Yes Yes No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes ...
result:
ok 95040 token(s): yes count is 29907, no count is 65133
Test #12:
score: -100
Wrong Answer
time: 44ms
memory: 5656kb
input:
95040 5 3 1 1 1 1 1 1 1 1 5 3 1 1 1 1 1 2 1 1 5 3 1 1 1 1 1 3 1 1 5 3 1 1 1 1 1 4 1 1 5 3 1 1 1 1 1 5 1 1 5 3 1 1 1 1 1 1 6 1 5 3 1 1 1 1 1 1 1 7 5 3 1 1 1 1 1 1 8 1 5 3 1 1 1 1 1 1 2 2 5 3 1 1 1 1 1 1 3 2 5 3 1 1 1 1 1 4 1 2 5 3 1 1 1 1 1 2 5 1 5 3 1 1 1 1 1 6 1 2 5 3 1 1 1 1 1 1 7 2 5 3 1 1 1 1 1 ...
output:
Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes 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 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 Yes Yes No No Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes Yes ...
result:
wrong answer expected NO, found YES [17153rd token]