QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#805859#9873. Last Chance: Threads of Despairdashenaaa#WA 1ms7816kbC++201.1kb2024-12-08 19:04:122024-12-08 19:04:13

Judging History

你现在查看的是最新测评结果

  • [2024-12-08 19:04:13]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7816kb
  • [2024-12-08 19:04:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pi pair<int,int>
#define vec vector<int>
#define int long long 
#define pb push_back
#define M 998244353
void in(int &x){
    int f=1;x=0;
    char c=getchar();
    while(!isdigit(c)&&c!='-')c=getchar();
    if(c=='-')f=-1,c=getchar();
    while(isdigit(c))x=x*10+c-'0',c=getchar();
    x*=f;
}
int t,n,m,k,x,y,a[1000005],b[1000005];
struct node{int x,tp;}d[1000005];
bool cmp(node q,node w){return q.x<w.x;}
void solve(){
    in(n);in(m);
    for(int i=1;i<=n;i++)in(a[i]);
    for(int i=1;i<=m;i++)in(b[i]);
    sort(a+1,a+1+n);sort(b+1,b+1+m);
    int s=0;
    if(a[1]==1){s=1;for(int i=1;i<=n;i++)if(a[i]!=1)s++,a[i]--;a[1]--;}
    else{s=max(0ll,n-b[1]);b[1]=0;for(int i=1;i<=n;i++)a[i]--;}
    sort(a+1,a+1+n);sort(b+1,b+1+m);int cur=0;
    for(int i=1,j=1,k=0;i<=n||j<=m;k++){
        if(j==m+1){puts("YES");return;}
        if(i<=n&&a[i]<=k){i++;continue;}
        if(j<=m&&b[j]<=k){j++;continue;}
        if(j<=m&&cur+b[j]-k<=s){cur+=b[j]-k;j++;continue;}
        puts("NO");return;
    }
    puts("YES");
}
signed main(){
    in(t);
    while(t--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 7756kb

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: 7816kb

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: 7748kb

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]