QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#805652 | #9873. Last Chance: Threads of Despair | LittleXi# | RE | 115ms | 4684kb | C++17 | 878b | 2024-12-08 17:48:07 | 2024-12-08 17:48:12 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=(a);i<=(b);i++)
#define Rof(i,a,b) for(int i=(a);i>=(b);i--)
#define db long double
#define ll long long
#define wln putchar('\n')
const int N=200005;
int n,m,a[N],b[N];
void Main()
{
scanf("%d%d",&n,&m);
For(i,1,n)scanf("%d",a+i),a[i]--;
For(i,1,m)scanf("%d",b+i);
sort(a+1,a+n+1);
sort(b+1,b+m+1);
int s=0,td=0;
For(i,1,n)
if(a[i]>0)s++;
int p=0;
if(a[1]==0)s++,td++,p=1;
while(p<n&&a[p+1]<=td)p++,td++;
For(i,1,m)
{
// printf("i=%d,s=%d,td=%d\n",i,s,td);
if(b[i]<=td)td++;
else if(b[i]-td<=s)s-=b[i]-td,td++;
else {printf("No\n"); return;}
while(p<n&&a[p+1]<=td)p++,td++;
}
printf("Yes\n");
}
int main()
{
int t;
scanf("%d",&t);
while(t--)Main();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3868kb
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: 3852kb
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: 3908kb
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: 3820kb
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: 3840kb
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: 1ms
memory: 3860kb
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: 2ms
memory: 3864kb
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: 3856kb
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: 3788kb
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: 42ms
memory: 3848kb
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: 0
Accepted
time: 46ms
memory: 3796kb
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:
ok 95040 token(s): yes count is 50357, no count is 44683
Test #13:
score: 0
Accepted
time: 53ms
memory: 3856kb
input:
108900 4 4 1 1 1 1 1 1 1 1 4 4 1 1 1 1 1 1 2 1 4 4 1 1 1 1 3 1 1 1 4 4 1 1 1 1 1 1 4 1 4 4 1 1 1 1 1 5 1 1 4 4 1 1 1 1 1 1 6 1 4 4 1 1 1 1 7 1 1 1 4 4 1 1 1 1 1 1 8 1 4 4 1 1 1 1 1 2 1 2 4 4 1 1 1 1 3 1 2 1 4 4 1 1 1 1 2 1 4 1 4 4 1 1 1 1 1 2 5 1 4 4 1 1 1 1 1 2 6 1 4 4 1 1 1 1 7 1 2 1 4 4 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:
ok 108900 token(s): yes count is 46206, no count is 62694
Test #14:
score: 0
Accepted
time: 64ms
memory: 3848kb
input:
50000 10 10 20 6 5 16 10 3 1 17 12 8 20 6 4 17 9 2 2 17 13 8 10 10 17 14 15 4 13 18 3 16 2 11 17 14 14 6 12 17 2 16 2 13 10 10 2 20 12 3 7 17 18 19 8 5 1 20 12 4 6 16 18 19 9 6 10 10 2 11 19 14 1 16 6 4 7 5 2 12 19 13 2 16 5 3 8 5 10 10 17 1 13 14 5 11 8 20 15 18 17 3 12 14 4 11 9 21 14 17 10 10 14 ...
output:
Yes No No Yes No Yes No No No No No No No Yes Yes Yes No No Yes Yes No Yes No No Yes No No No Yes No Yes No Yes Yes No No Yes Yes No No No Yes Yes No Yes Yes No Yes Yes Yes No No Yes Yes No No No No Yes No No No Yes No No No Yes Yes No Yes Yes No Yes Yes No Yes No No Yes Yes Yes Yes No No Yes No No ...
result:
ok 50000 token(s): yes count is 19646, no count is 30354
Test #15:
score: 0
Accepted
time: 56ms
memory: 3904kb
input:
33333 12 15 9 7 15 17 13 18 8 14 10 25 11 22 9 6 14 17 15 17 8 13 9 24 13 22 26 1 21 12 15 8 20 15 25 6 24 23 4 26 13 18 5 7 19 16 27 5 23 24 3 25 14 17 4 9 1 16 12 15 26 16 14 8 20 11 1 5 2 15 12 4 26 16 15 8 19 10 1 4 3 14 12 5 9 24 12 12 15 17 13 15 19 4 25 1 22 6 2 27 16 17 13 15 18 3 24 2 23 5 ...
output:
No No Yes No Yes Yes No No No Yes Yes No No No No No Yes No Yes No Yes No No Yes No Yes No Yes No Yes Yes Yes No Yes Yes No Yes No No No No No No No No No No No Yes Yes No No No No Yes No No No Yes No Yes Yes Yes Yes No No No Yes No No No No No No No Yes No Yes No No No No Yes No No Yes No No Yes No...
result:
ok 33333 token(s): yes count is 11692, no count is 21641
Test #16:
score: 0
Accepted
time: 54ms
memory: 3908kb
input:
33333 15 12 21 1 4 15 9 23 5 6 10 19 17 24 3 2 18 22 1 5 15 8 24 5 6 9 20 19 23 15 12 11 3 22 7 21 10 13 16 23 26 9 20 19 4 27 12 5 21 7 23 10 13 15 22 27 10 19 15 12 12 7 20 10 17 4 25 15 11 27 8 14 6 13 18 11 9 20 11 19 3 24 16 10 29 7 14 15 12 2 3 5 24 11 26 19 10 27 14 25 15 20 18 12 3 3 6 24 11...
output:
Yes No No No Yes Yes No No No No No No No No Yes No No Yes Yes No Yes No No No No No No Yes No No No No No Yes No Yes No No No Yes No Yes Yes Yes No Yes Yes Yes Yes No Yes Yes No No No No No No Yes Yes No No No No Yes Yes No No No No Yes No No Yes No Yes No No No Yes Yes No No No No No Yes No Yes Ye...
result:
ok 33333 token(s): yes count is 13098, no count is 20235
Test #17:
score: 0
Accepted
time: 72ms
memory: 3812kb
input:
5000 100 100 133 5 137 121 30 141 27 123 178 128 171 21 67 74 175 47 26 82 125 48 65 102 106 89 179 43 60 164 136 46 9 159 111 144 59 198 157 93 28 169 12 186 42 29 183 87 56 8 139 22 154 161 109 101 168 130 17 182 103 147 132 33 129 158 23 195 53 35 138 185 51 114 126 10 57 7 62 99 55 191 176 199 1...
output:
No No No Yes Yes No No No No No No No No No Yes No No No No Yes No No No Yes No No No Yes No No No No No No No No Yes No No No No No Yes Yes No Yes No No No Yes No No No No No No No No No No No No No No No No No No Yes Yes No No No Yes No No Yes Yes No No No Yes Yes No Yes Yes No No No No No No No N...
result:
ok 5000 token(s): yes count is 1091, no count is 3909
Test #18:
score: 0
Accepted
time: 87ms
memory: 3920kb
input:
500 1000 1000 410 461 57 202 1577 1597 994 944 1488 956 379 380 1486 1780 1244 1921 1794 265 1563 1679 243 65 1079 192 1839 762 1014 206 23 193 1185 1746 822 948 1397 1854 917 645 623 1726 809 1708 1765 1908 761 527 1603 1073 758 46 1592 203 1871 1873 1252 438 808 416 1128 1099 1107 735 151 1959 171...
output:
No No No No Yes Yes No No No No No No No No No No No No No No No No No No Yes Yes No No No No No No No Yes No No No No No Yes Yes No No No No No Yes No Yes Yes No No No Yes No No No No Yes No No No No No Yes Yes No No No No No No No No No Yes No No No No No Yes No Yes No No No Yes No No No No No No ...
result:
ok 500 token(s): yes count is 70, no count is 430
Test #19:
score: 0
Accepted
time: 115ms
memory: 4684kb
input:
5 100000 100000 192348 43709 194484 134138 36415 165204 147428 196982 14278 195617 146117 168812 110270 1094 192657 135027 9041 181689 170958 162867 32338 18546 107477 98466 52702 82906 28257 89818 72376 34525 22246 170527 118863 160364 47995 153027 163962 98710 132547 38225 198231 78342 115823 4907...
output:
No No No No No
result:
ok 5 token(s): yes count is 0, no count is 5
Test #20:
score: -100
Runtime Error
input:
1 500000 500000 298323 92801 517022 733075 950589 442461 98931 873034 365485 969370 407317 138461 421780 932696 964828 249894 562117 873629 795988 841659 25700 657972 879460 790648 337233 96409 76314 442433 323234 93538 461415 502833 763238 606519 203793 398485 683063 957433 104205 604635 952026 185...