QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#807462#9873. Last Chance: Threads of DespairWzy#WA 1ms3864kbC++141.5kb2024-12-10 00:20:582024-12-10 00:20:58

Judging History

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

  • [2024-12-10 00:20:58]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3864kb
  • [2024-12-10 00:20:58]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
typedef  long long LL;
typedef pair<LL,LL> PII;
const int N=2e5+10,M=2e6;
const int mod=998244353;
const LL P=1e9+7;
const LL INF=1e18;
LL h[N],e[M],ne[M],w[M],idx;

int n;


void solve(){
   int n,m;
   cin>>n>>m;

   int cnt=0,nw=0;

   vector<int> a,b;

   bool fg=false;
   for(int i=0;i<n;i++){
        int  x;
        cin>>x;

         if(x==1&&!fg){
            fg=true,cnt++,nw++;
            continue;
        }
        else if(x==1){
            nw++;
            continue;
        }

        cnt++;
        a.push_back(x-1);
   }

   for(int i=0;i<m;i++){
        int x;
        cin>>x;

        b.push_back(x);
   }

   sort(a.begin(),a.end());
   sort(b.begin(),b.end());
   //cout<<nw<<" "<<cnt<<endl;
   bool sg=true;
   multiset<int> st;
   int i=0,j=0;

   while(j<m){
        //cout<<1<<endl;
        //cout<<b[j]<<endl;
        //cout<<cnt<<" "<<nw<<endl;
        //cout<<b[j]-nw<<endl;
        if(nw>=b[j]) j++,nw++;
        else if(b[j]-nw<=cnt) {
            cnt-=b[j]-nw;
            nw++,j++;
        }
        else sg=false,j++;
        //cout<<b[j]<<endl;
        //cout<<cnt<<" "<<nw<<endl;

        while(i<a.size()&&nw>=a[i]) i++,nw++;

   }

   if(sg) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T=1;
    cin>>T;

    while(T--) solve();
 
    return 0;
}

详细

Test #1:

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

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

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

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

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

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: -100
Wrong Answer
time: 1ms
memory: 3572kb

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
No
No
Yes
Yes
No
No
No
No
No
No
No
No
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes
Yes...

result:

wrong answer expected YES, found NO [59th token]