General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
214449308 Practice:
algoplutus
1557B - 40 C++20 (GCC 11-64) Time limit exceeded on test 2 2000 ms 2372 KB 2023-07-19 10:43:44 2023-07-19 10:43:44
→ Source
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma comment(linker, "/stack:200000000")
 
#include <bits/stdc++.h>
using namespace std;
#define Swastick ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<long long, long long>
#define vi vector<int>
#define vll vector<long long>
#define mii map<int, int>
#define mll map<long long, long long>
#define si set<int>
#define sll set<long long>
#define sc set<char>
#define nL "\n"
#define pb push_back
#define mp make_pair
 
#define debug(a,b) cout<<a<<": "<<b<<endl
#define Debug cout<<"Reached here"<<endl
 
#define f(i,s,e) for(long long int i=s;i<e;i++)
#define cf(i,s,e) for(long long int i=s;i<=e;i++)
#define rf(i,e,s) for(long long int i=e;i>=s;i--)
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define eb emplace_back
#define sz(x) ((int)x.size())
#define fe first
#define se second
 
 
#define PI 3.1415926535897932384626433832795l 
const int MAX_N = 1e5 + 5;
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
const ld EPS = 1e-9;
#define read(type) readInt<type>()
ll min(ll a,int b) { if (a<b) return a; return b; }
ll min(int a,ll b) { if (a<b) return a; return b; }
ll max(ll a,int b) { if (a>b) return a; return b; }
ll max(int a,ll b) { if (a>b) return a; return b; }
ll gcd(ll a,ll b) { if (b==0) return a; return gcd(b, a%b); }
ll lcm(ll a,ll b) { return a/gcd(a,b)*b; }
string to_upper(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='a' && a[i]<='z') a[i]-='a'-'A'; return a; }
string to_lower(string a) { for (int i=0;i<(int)a.size();++i) if (a[i]>='A' && a[i]<='Z') a[i]+='a'-'A'; return a; }
bool prime(ll a) { if (a==1) return 0; for (int i=2;i<=round(sqrt(a));++i) if (a%i==0) return 0; return 1; }
void yes() { cout<<"YES\n"; }
void no() { cout<<"NO\n"; }
 
void showVec(vll v){
  for(auto &x:v) cout<<x<<" ";
  cout<<nL;
}

ll binSrch(vll v,ll k){
    ll l=0,h=v.size()-1;
    while(h>=l){
        ll mid=l+(h-l)/2;
        if (v[mid]==k){
            return mid;
        }
        else if(v[mid]>k){
            h=mid-1;
        }
        else {
            l=mid+1;
        }
    }
    return -1;
}

void solve(){
  ll n,k;
  cin>>n>>k;
  vll v(n);
  for(auto &i:v) cin>>i;
  vll vs=v;
  sort(all(vs));
  // if(v==vs){
  //   yes();
  //   return;
  // }
  ll cntc=0,cnts=0;
  f(i,0,n){
    ll a=binSrch(vs,v[i]);
    if(v[i+1]==vs[a+1]){
      while(v[i+1]==vs[a+1]){
        i++;
        a++;
      }
      cntc++;
    }
    else{
      cnts++;
    }
  }
  if(k>=cntc+cnts) yes();
  else no();
}
 
signed main(){
  Swastick
  ll testCases=1;
  cin>>testCases;
  while(testCases--) solve();
  return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details