ankit_verma's blog

By ankit_verma, history, 3 months 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.

Read more »

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

By ankit_verma, history, 3 months ago, In English

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

Question Link-Question Link

Submission Link-Submission

Read more »

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