博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Diverse Team
阅读量:5250 次
发布时间:2019-06-14

本文共 2464 字,大约阅读时间需要 8 分钟。

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 315 13 15 15 12
Output
Copy
YES1 2 5
Input
Copy
5 415 13 15 15 12
Output
Copy
NO
Input
Copy
4 420 10 40 30
Output
Copy
YES1 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 
2 #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 }
ac代码

 

 

 

转载于:https://www.cnblogs.com/focus5679/p/9286125.html

你可能感兴趣的文章
如何在.xml文件中配置Servlet信息
查看>>
使用AVCaptureSession捕捉静态图片
查看>>
redis enable TLS
查看>>
bugku web 头等舱
查看>>
java学习之多态(转型、特点)
查看>>
Convert.ToInt32、int.Parse(Int32.Parse)、int.TryParse三者之间的区别
查看>>
python 获取本机ip
查看>>
oracle 12.2版本优化情况
查看>>
kindeditor异步加载 无法初始化
查看>>
JSP九大内置对象及四个作用域
查看>>
分别让用户输入用户名和密码,如果用户名不为admin,则提示“用户名不存在”...
查看>>
mysql导入txt文件
查看>>
数据库 T-sql 基础语句
查看>>
中国人创业的四个阶段:同心协力——同床异梦——同室操戈——同归于尽
查看>>
洛谷 P1709 隐藏口令Hidden Password
查看>>
HDU 1698 Just a Hook
查看>>
性能调优攻略
查看>>
给我们的Empty Object加个图标
查看>>
深入理解Java中的String
查看>>
Centos7安装并配置mysql5.6完美教程
查看>>