-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCandies.cpp
More file actions
36 lines (34 loc) · 818 Bytes
/
Copy pathCandies.cpp
File metadata and controls
36 lines (34 loc) · 818 Bytes
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
#define ll long long
#define f(end) for(int i=0;i<end;i++)
#define e '\n'
#include <bits/stdc++.h>
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t,n;
cin>>t;
while(t--)
{
cin>>n;
n*=2;
ll a[n]={0},max=INT_MIN;
bool ans=true;
f(n) cin>>a[i];
f(n){
int count=0;
for(int j=0;j<n;j++){
if(a[i]==a[j]){ count++;}
if(count>2){
ans=false;
break;
}
}
}
if(ans) cout<<"YES"<<e;
else cout<<"NO"<<e;
}
return 0;
}
// we take the numbers in array and we check if the number appears more than 2 then it is not possible to split it into 2 parts
// where all the numbers are distinct as one of the 2 array will have 2 elements same