There are n
students in a school class, the rating of the i-th student on Codehorses is ai. You have to form a team consisting of k students (1≤k≤n
) such that the ratings of all team members are distinct.
If it is impossible to form a suitable team, print "NO" (without quotes). Otherwise print "YES", and then print k
distinct numbers which should be the indices of students in the team you form. If there are multiple answers, print any of them.
The first line contains two integers n
and k (1≤k≤n≤100
) — the number of students and the size of the team you have to form.
The second line contains n
integers a1,a2,…,an (1≤ai≤100), where ai is the rating of i
-th student.
If it is impossible to form a suitable team, print "NO" (without quotes). Otherwise print "YES", and then print k
distinct integers from 1 to n
which should be the indices of students in the team you form. All the ratings of the students in the team should be distinct. You may print the indices in any order. If there are multiple answers, print any of them.
Assume that the students are numbered from 1
to n
.
5 315 13 15 15 12
YES1 2 5
5 415 13 15 15 12
NO
4 420 10 40 30
YES1 2 3 4
All possible answers for the first example:
- {1 2 5}
- {2 3 5}
- {2 4 5}
Note that the order does not matter.
1 #include2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 14 #define mod 100000000715 const int INF = 0x3f3f3f3f;16 typedef long long ll;17 const int maxn = 15;18 using namespace std;19 20 int n, k;21 bool flag;22 int ans[105];23 bool vis[105];24 25 int main()26 {27 memset(vis, 0, sizeof(vis));28 scanf("%d%d", &n, &k);29 int cnt = 0;30 for(int i = 0; i < n; i++)31 {32 int temp;33 scanf("%d", &temp);34 if(!vis[temp])35 {36 vis[temp] = true;37 ans[cnt++] = i;38 }39 }40 if(cnt >= k)41 {42 printf("YES\n");43 for(int i = 0; i < k ; i++)44 {45 if(i == k-1)46 {47 printf("%d\n", ans[i]+1);48 continue;49 }50 printf("%d ", ans[i]+1);51 }52 }53 else54 printf("NO\n");55 return 0;56 }