Codeforces Round #737 (Div. 2) question b

Revision en4, by _WATerror_AK, 2021-08-09 23:33:09

question Link

void solve()
{
	int n,k;
        cin>>n>>k;
        int a[n];
        vector<pii>v;
        for(int i=0;i<n;i++){
            cin>>a[i];
            v.pb({a[i],i});
        }
        sort(v.begin(),v.end());
        int z=0;
        for(int i=0;i<n-1;i++){
            if(v[i+1].ss!=v[i].ss+1)z++;
        }
        
        if(z>0)z++;
        deb(z);
        if(z>k)cout<<"No"<<endl;
        else cout<<"Yes"<<endl;
}

what's wrong with this code? I don't understand why it is giving the wrong answer.

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en5 English _WATerror_AK 2021-08-09 23:34:22 325
en4 English _WATerror_AK 2021-08-09 23:33:09 360
en3 English _WATerror_AK 2021-08-09 23:32:17 20
en2 English _WATerror_AK 2021-08-09 23:31:37 62
en1 English _WATerror_AK 2021-08-09 23:30:07 559 Initial revision (published)