-
Notifications
You must be signed in to change notification settings - Fork 0
/
B.cpp
63 lines (62 loc) · 1.08 KB
/
B.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include<bits/stdc++.h>
#include<cmath>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL)
int main()
{
fastio;
long long n,k,m,i,count=0,x=0,p=0,q;
static long long ara[100005],mo[100005];
cin>>n>>k>>m;
for(i=0;i<n;i++)
{
cin>>ara[i];
mo[i]=ara[i]%m;
}
sort(mo,mo+n);
for(i=0;i<n;i++)
{
if(i==0)
{
count=1;
x=1;
}
if(i==n-1)
{
count=max(x,count);
x=1;
}
if(mo[i]==mo[i+1] && i!=n-1)
{
x++;
}
else
{
count=max(x,count);
x=1;
}
if(count>=k)
{
q=mo[i];
p=1;
break;
}
}
if(p==0)
cout<<"No"<<"\n";
else
{
cout<<"Yes"<<"\n";
for(i=0;i<n;i++)
{
if(k==0)
break;
if(ara[i]%m==q)
{
cout<<ara[i]<<" ";
k--;
}
}
}
return 0;
}