_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.

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

| Write comment?
»
3 years ago, # |
  Vote: I like it 0 Vote: I do not like it

Try for the following testcase: n=4 k=2 v=[1, 7, 5, 6]