Diverse Team

A. Diverse Team
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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 (1kn

) 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.

Input

The first line contains two integers n

and k (1kn100

) — the number of students and the size of the team you have to form.

The second line contains n

integers a1,a2,,an (1ai100), where ai is the rating of i

-th student.

Output

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

.

Examples
Input
Copy
5 3
15 13 15 15 12
Output
Copy
YES
1 2 5 
Input
Copy
5 4
15 13 15 15 12
Output
Copy
NO
Input
Copy
4 4
20 10 40 30
Output
Copy
YES
1 2 3 4 
Note

All possible answers for the first example:

  • {1 2 5}
  • {2 3 5}
  • {2 4 5}

Note that the order does not matter.

 

 1 #include <set>
 2 #include <cmath>
 3 #include <queue>
 4 #include <stack>
 5 #include <vector>
 6 #include <string>
 7 #include <cstdio>
 8 #include <cstdlib>
 9 #include <cstring>
10 #include <iostream>
11 #include <algorithm>
12 #include <functional>
13 
14 #define mod 1000000007
15 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     else
54         printf("NO\n");
55     return 0;
56 }
ac代码

 

 

 

posted @ 2018-06-24 12:01  focus5679  阅读(115)  评论(0编辑  收藏  举报