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.
Try for the following testcase:
n=4 k=2 v=[1, 7, 5, 6]