QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#818057 | #9873. Last Chance: Threads of Despair | xinlengweishang | WA | 79ms | 5908kb | C++20 | 1.1kb | 2024-12-17 16:05:56 | 2024-12-17 16:05:57 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
using namespace std;
bool cmp(ll a,ll b){
return a<b;
}
ll h1[1000010],h2[1000010];
void slove(){
ll n,m;
ll hit=0;
ll k=0;
int temp=1;
scanf("%lld%lld",&n,&m);
for(int i=1;i<=n;i++){
scanf("%lld",&h1[i]);
if(h1[i]>1) hit++,h1[i]--;
else if(h1[i]==1&&temp){
temp=0;
hit++;
h1[i]--;
}
}
for(int i=1;i<=m;i++){
scanf("%lld",&h2[i]);
}
sort(h1+1,h1+n+1,cmp);
sort(h2+1,h2+m+1,cmp);
int i=1,j=1;
int cnt=1;
while(1){
if(cnt++>100) break;
// printf("hit=%lld k=%d i=%d j=%d\n",hit,k,i,j);
if(j>m) break;
if(hit<0) break;
if(i<=n&&h1[i]<=k){
i++;
k++;
continue;
}
if(j<=m&&h2[j]<=k){
j++;
k++;
continue;
}
// printf("hit=%lld k=%d i=%d j=%d\n",hit,k,i,j);
if(j>m) break;
if(hit<0) break;
hit-=h2[j]-k;
h2[j]=k;
}
if(hit>=0) printf("YES\n");
else printf("No\n");
return ;
}
int main(){
int T;
scanf("%d",&T);
while(T--) slove();
return 0;
}
/*
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
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5760kb
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: 5812kb
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: 5904kb
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: 5724kb
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: 1ms
memory: 5776kb
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: 5796kb
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: 5908kb
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: 5828kb
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: 5904kb
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: 5ms
memory: 5728kb
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: 5900kb
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: 5756kb
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: 52ms
memory: 5896kb
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: 66ms
memory: 5796kb
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: 60ms
memory: 5824kb
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: 59ms
memory: 5712kb
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: -100
Wrong Answer
time: 79ms
memory: 5728kb
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:
YES YES No YES YES No YES No YES No YES No No No YES YES No No No YES No YES No YES No No No YES No YES No YES No No No No YES YES No No No No YES YES YES YES No YES No YES YES YES No No No No No No No YES No No YES No No No No No YES YES YES No YES YES No YES YES YES No YES No YES YES No YES YES No...
result:
wrong answer expected NO, found YES [1st token]