-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathB.cpp
38 lines (36 loc) · 738 Bytes
/
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
#include<bits/stdc++.h>
#include<string>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
int ara[100006];
int main()
{
fastio;
int t,n,i,k,ans;
cin>>t;
while(t--)
{
vector<pair<int,int> > vect;
ans=0;
cin>>n>>k;
for(i=1;i<=n;i++){
cin>>ara[i];
vect.push_back(make_pair(ara[i],i));
}
sort(vect.begin(),vect.end());
for(i=1;i<n;i++)
{
if(vect[i].second<vect[i-1].second)
{
ans=n-i;
break;
}
}
if(ans%k==0)
ans/=k;
else
ans=ans/k+1;
cout<<ans<<"\n";
}
return 0;
}