fork download
  1. //INCLUDING..
  2. #include <bits/stdc++.h>
  3. #include <iostream>
  4. #include <algorithm>
  5. #include <cmath>
  6. #include <vector>
  7. #include <stack>
  8.  
  9.  
  10. //DEFINING..
  11. #define LL long long
  12. #define all(a) a.begin(),a.end()
  13. #define rall(a) a.rbegin(),a.rend()
  14. #define lop(i,n) for(int i=0;i<n;i++)
  15. #define pb(a) push_back(a)
  16. #define sz(s) (s).size()
  17. #define cy cout<<"YES\n";
  18. #define cn cout<<"NO\n";
  19. #define vi vector<int>
  20. #define F first
  21. #define S second
  22. #define fast ios::sync_with_stdio(NULL); cin.tie(0); cout.tie(0);
  23. using namespace std;
  24.  
  25.  
  26. //FUNCTION..
  27.  
  28. bool isPrime(int num)
  29. {bool flag = true;for (int i = 2; i <= sqrt(num); i++) if (num % i == 0) {flag = false;break;} return flag;}
  30. int lcm(int a ,int b)
  31. {return a*b/__gcd(a,b);}
  32. int digitsum(int n)
  33. {int ret=0;while(n){ret+=n%10;n/=10;}return ret;}
  34. bool compare(const pair<int,int> &a,const pair<int,int> &b)
  35. {if(a.first == b.first){return a.second < b.second;} return a.first > b.first;}
  36. int powar(int x,int y,int m)
  37. {if(y==0)return 1; int p=powar(x,y/2,m)%m; p=(p*p)%m;return (y%2==0)?p:(x*p)%m;}
  38. int modInverse(int a , int m)
  39. {return powar(a , m - 2 , m);}
  40.  
  41.  
  42. const int M=1e9+7;
  43. LL n,m,k,flag;
  44. char ch;
  45. map<LL ,LL> mp;
  46.  
  47. //SOLVING..
  48.  
  49.  
  50. void SOLVE(){
  51. cin>>n>>k;
  52. vector<pair<LL , LL>> ar(n);
  53. for(int i=0;i<n;i++) {
  54. cin>>ar[i].F;
  55. ar[i].S=i;
  56. }
  57. sort(all(ar));
  58. int val=1;
  59. for(int i=1;i<n;i++){
  60. if(ar[i-1].S+1 != ar[i].S)val++;
  61. }
  62. if(val<=k)cy
  63. else cn
  64.  
  65. }
  66.  
  67. //MAINING..
  68. signed main(){
  69. fast
  70. int T=1;
  71. cin>>T;
  72. while(T--)
  73. SOLVE();
  74. return 0;
  75. }
Success #stdin #stdout 0.01s 5316KB
stdin
Standard input is empty
stdout
NO