-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCard Exchange
66 lines (62 loc) · 1.81 KB
/
Card Exchange
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
64
65
66
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define ll long long
#define pb push_back
#define YY cout<<"YES"
#define NN cout<<"NO"
#define maxHeap priority_queue<ll>
#define minHeap priority_queue<ll, vll, greater<ll>>
#define auto_initialize(arr,n) ll n;cin>>n;vll arr(n);for(ll i=0;i<n;i++){cin>>arr[i];}
#define inf 1e18
#define ff first
#define ss second
#define vll vector<ll>
#define all(x) (x).begin(),(x).end()
#define read(x) ll x;cin>>x;
#define el "\n"
#define sync ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
template<typename T> istream& operator >>(istream &in, vector<T> &v) { for (auto &x : v) in >> x; return in;}
template<typename T> ostream& operator <<(ostream &out, const vector<T> &v) { for (auto &x : v) out << x << ' '; return out;}
template<typename T1, typename T2> istream& operator >>(istream &in, pair<T1, T2> &p) { in >> p.first >> p.second; return in;}
template<typename T1, typename T2> ostream& operator <<(ostream &out, const pair<T1, T2> &p) { out << p.first << ' ' << p.second; return out;}
// Read Question Twice.
// Always check for contraints.
// Think twice before submitting code.
//ll binExp(ll a,ll b,ll m){
// ll res=1;
// while(b>0){
// if(b&1){
// res=(res*a)%m;
// }
// a=(a*a)%m;
// b>>=1;
// }
// return res;
//}
void testcase() {
ll n, k; cin >> n >> k;
vll a(n); cin >> a;
map<ll, ll>mp;
for (ll i : a) mp[i]++;
for (auto it : mp) {
if (it.ss >= k) {
cout << k - 1;
return;
}
}
cout << n;
}
int main() {
sync;
ll t = 1;
cin >> t;
ll k = 1;
while (t--) {
//cout << "Case #" << k++ << ": ";
testcase();
cout << el;
}
return 0;
}