-
Notifications
You must be signed in to change notification settings - Fork 0
/
Day_080.cpp
47 lines (42 loc) · 963 Bytes
/
Day_080.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
/**
*Problem Statement: Alice and Bob went to a pet store. There are N animals in the store where the ith animal is
of type Ai?.Alice decides to buy some of these N animals. Bob decides that he will buy all the animals left
in the store after Alice has made the purchase.Find out whether it is possible that Alice and Bob end up with
exactly same multiset of animals.
*Author: Kunal Kathpal (https://github.com/kunal-2002)
*/
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
int main(){
cout<<"Enter number of test cases:\t";
int T;
cin>>T;
while(T--){
ll n;
cin>>n;
ll a[n];
map<ll,ll>mp;
set<ll>s;
bool ok = true;
for(int i=0; i<n; i++){
cin>>a[i];
mp[a[i]]++;
s.insert(a[i]);
}
for(auto it = s.begin(); it!=s.end();it++){
ll temp = mp[*it];
if(temp%2){
ok = false;
}
}
if(ok){
cout<<"YES"<<endl;
}
else{
cout<<"NO"<<endl;
}
}
return 0;
}