QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#804385 | #9873. Last Chance: Threads of Despair | ucup-team5697# | WA | 1ms | 5840kb | C++14 | 903b | 2024-12-07 22:13:22 | 2024-12-07 22:13:32 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;bool Mbe;
namespace MAOJUN{
typedef long long ll;
const int N=5e5+5;
int n,m,a[N],b[N*2];
inline void slv(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)scanf("%d",&a[i]);
for(int i=1;i<=m;i++)scanf("%d",&b[i]);
sort(a+1,a+n+1);sort(b+1,b+m+1);
int X=0;
for(int i=1;i<=n;i++)X+=a[i]>1;
for(int i=1;i<=n;i++)if(a[i]>1)a[i]--;
if(a[1]==1)X++;
else X--;
for(int i=1,j=1,k=1;j<=m;){
if(i<=n&&a[i]<=max(1,k-1)){i++;k++;}
else if(b[j]<=max(1,k-1)){j++;k++;}
else{X-=b[j]-max(1,k-1);j++;k++;}
}
puts(X>=0?"Yes":"No");
}
inline void main(){int T;scanf("%d",&T);while(T--)slv();}
}bool Med;int main(){
#ifdef LOCAL
freopen("2.in","r",stdin);
freopen("data.out","w",stdout);
atexit([]{fprintf(stderr,"%.0lfms\n%lfMB\n",clock()*1000./CLOCKS_PER_SEC,(&Mbe-&Med)/1024./1024);});
#endif
MAOJUN::main();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5840kb
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: 5696kb
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: -100
Wrong Answer
time: 1ms
memory: 5772kb
input:
4 1 1 1 1 1 1 1 2 1 1 2 1 1 1 2 2
output:
Yes Yes Yes Yes
result:
wrong answer expected NO, found YES [4th token]