-
Notifications
You must be signed in to change notification settings - Fork 1
/
DSA01010.cpp
48 lines (45 loc) · 886 Bytes
/
DSA01010.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
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--)
{
int n,k;
cin>>n>>k;
int a[k+1];
int b[k+1];
for(int i=1;i<=k;i++)
{
cin>>a[i];
b[i] = a[i];
}
int i=k;
int fl=0;
while(i>0 and a[i]==n-k+i)
i--;
if(i>0)
{
a[i]+=1;
for(int j=i+1;j<=k;j++)
a[j] = a[i]+j-i;
}
else
{
cout<<k<<endl;
fl=1;
}
int cnt=0;
if(!fl)
{
for(int i=1;i<=k;i++)
for(int j=1;j<=k;j++)
{
if(a[i]==b[j])
cnt++;
}
cout<<k-cnt<<endl;
}
}
}