-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcf_2.cpp
70 lines (49 loc) · 1.17 KB
/
cf_2.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
64
65
66
67
68
69
70
#include<bits/stdc++.h>
using namespace std ;
using ll = long long;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
ll t,n;
cin>>t;
while(t--){
cin>>n;
ll ar[2*n];
map<ll,ll> mp;
for(ll i=0;i<2*n;i++){
cin>>ar[i];
mp[ar[i]]++;
}
vector<ll> v;
ll flag=1;
for(auto it: mp){
if(it.second!=2){
flag=0;break;
}
for(ll i=0;i<it.second/2;i++){
v.push_back(it.first);
}
}
// pr(v,flag);
sort(v.begin(),v.end());reverse(v.begin(),v.end());
if(!flag){
cout<<"NO\n";continue;
}
ll prev=0;
set<ll> st;
for(ll i=0;i<v.size();i++){
ll curr=v[i]-prev;
ll temp=n-i;
temp*=(ll)2;
if(curr%temp!=0 || curr==0 || curr<0){
flag=0;
break;
}
st.insert(curr/temp);
prev+=(ll)2*(curr/temp);
}
if(flag && st.size()==n)
cout<<"YES\n";
else
cout<<"NO\n";
}
}