forked from kothariji/competitive-programming
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCodeforces_#Div-2_Prob-B.cpp
71 lines (67 loc) · 1.13 KB
/
Codeforces_#Div-2_Prob-B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define itr(type) vector<type>::iterator
#define cons 1000000007
#define ll long long
#define ld long double
#define prec(t) cout<<setiosflags(ios::fixed), cout<<setprecision(t)
#define width(t,x) cout<<setw(t), cout<<setfill(x)
#define dbg1(x) {cout<<#x<<"="<<x<<"\n";}
#define dbg2(x) for(auto z:x){cout<<z<<" ";} cout<<"\n";
#define dbg3(x) for(auto z:x){cout<<z.first<<" "<<z.second<<"\n";}
#define fin freopen("input.txt","r",stdin);
#define fout freopen("output.txt","w",stdout);
bool comp(pair<int,int> a,pair<int,int> b)
{
return (a.second<b.second);
}
int solve()
{
int n,k;
cin>>n>>k;
vector<pair<int,int>> v;
for (int i = 0; i < n; ++i)
{
int x;
cin>>x;
v.pb(mp(x,i));
}
sort(v.begin(),v.end());
int i=1;
int count=n;
while(i<n)
{
if (v[i].second-v[i-1].second==1)
{
while(v[i].second-v[i].second==1)
{
i++;
}
count--;
}
i++;
}
if (count==1)
{
count=0;
}
if (count<=k)
{
cout<<"Yes\n";
}
else
cout<<"No\n";
return 0;
}
int main()
{
int tt=1;
cin>>tt;
while(tt--)
{
solve();
}
return 0;
}