_WATerror_AK's blog

By _WATerror_AK, history, 3 years ago, In English

question Link

int n,k;
	cin >> n >>k;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		   cin>>a[i];
	}
    int ans=1;
    for(int i=1;i<n;i++){
        if(a[i]>=a[i-1]){
            continue;
        }else{
            ans++;
        }
    }
    //deb(ans);
    if(ans<=k){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }

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

Full text and comments »

  • Vote: I like it
  • -1
  • Vote: I do not like it

By _WATerror_AK, history, 3 years ago, In English

Can anyone help me out with my code to optimise this code.

Question Link-Question Link

Submission Link-Submission

Full text and comments »

  • Vote: I like it
  • -9
  • Vote: I do not like it