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;
}

 

发布了153 篇原创文章 · 获赞 43 · 访问量 6万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 技术黑板 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览