赞
踩
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> #include <queue> #include <set> #include <map> #include <cstring> using namespace std; typedef long long ll; int n; void solve(){ cin >> n; vector<ll> v; for (int i = 0; i < 2 *n; ++i) { ll x; cin >> x; v.push_back(x); } sort(v.rbegin(), v.rend()); v.erase(unique(v.begin(), v.end()), v.end()); if (v.size() != n){ cout << "NO\n"; return; } int div = n << 1; vector<ll> a; a.push_back(0); for (int i = 0; i < n; ++i) { ll sum = v[i]; if (i >= 1) a[i] += a[i - 1]; sum -= 2*a[i]; if (sum > 0 && sum % div == 0){ a.push_back(sum / div); div -= 2; }else{ cout << "NO\n"; return; } } cout << "YES\n"; } int main(){ ios::sync_with_stdio(false); cin.tie(), cout.tie(); int cases; cin >> cases; while (cases--){ solve(); } return 0; }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。