Codeforce Round #486 (Div.3) A 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 nn students in a school class, the rating of the ii-th student on Codehorses is aiai. You have to form a team consisting of kk students (1≤k≤n1≤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 kk 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 nn and kk (1≤k≤n≤1001≤k≤n≤100) — the number of students and the size of the team you have to form.

The second line contains nn integers a1,a2,…,ana1,a2,…,an (1≤ai≤1001≤ai≤100), where aiai is the rating of ii-th student.

Output

If it is impossible to form a suitable team, print "NO" (without quotes). Otherwise print "YES", and then print kk distinct integers from 11 to nn 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 11 to nn.

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.

题意:给你n个数字,能不能在里面找到k个不同的数字,如果能就输出YES,再输出这些数字的下标(1<<i<<n);不能就输出NO。

#include<bits/stdc++.h>
using namespace std;
int main(){
	int m,n;
	int a[200];
	while(cin>>m>>n){
		set<int> s;       //集合,直接统计出一共多少不同的数字 
		vector<int> b;
	    vector<int> ans;
		memset(a,0,sizeof(a));
		for(int i=1;i<=m;i++){
			cin>>a[i];
			s.insert(a[i]);
		}
		int sum=s.size();    
		if(n>sum){                 //没那么多,直接输出NO 
			cout<<"NO"<<endl;
			continue;
		}
		else {
		     cout<<"YES"<<endl;
			 set<int>::iterator it;
			 for(it=s.begin();it!=s.end();it++)
			 {  
				b.push_back(*it);              //取集合的元素到vector(方便操作) 
			 }
	 
			 for(int i=1;i<=m;i++){        //从a[i]里直接找,从左往右, 
				for(int j=0;j<sum;j++){
					if(b[j]==a[i]){
						ans.push_back(i);        //找到就把下标记下来 
						b.erase(b.begin()+j);    //把vector中被找到的删除 
						sum--;
						break;
					}
				} if(ans.size()==n)           //找了k个,跳出循环(这里的n即题目的k) 
				   break;
			 }


		   sort(ans.begin(),ans.end());
		   for(int i=0;i<ans.size();i++)
			cout<<ans[i]<<" ";
			cout<<endl;
}
}
	return 0;
}

 

全部评论

相关推荐

05-12 11:09
已编辑
门头沟学院 后端
已注销:没必要放这么多专业技能的描述。这些应该是默认已会的,写这么多行感觉在凑内容。项目这块感觉再包装包装吧,换个名字,虽然大家的项目基本都是网上套壳的,但是你这也太明显了。放一个业务项目,再放一个技术项目。技术项目,例如中间件的一些扩展和尝试。
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务