Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #define debug(tl) cerr<<#tl<<' '<<tl<<'\n';
- #include "bits/stdc++.h"
- using namespace std;
- #define all(d) d.begin(), d.end()
- typedef long long ll;
- typedef pair<ll, ll> pll;
- typedef pair<int, int> pii;
- typedef long double ld;
- signed main() {
- #ifdef _DEBUG
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- ios_base::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- srand(time(NULL));
- ll t;
- cin >> t;
- while (t--) {
- ll n;
- cin >> n;
- vector<ll> a(n);
- multiset<ll> x;
- ll sum = 0;
- ll cnt0 = 0;
- for (ll i = 0; i < n; i++) {
- cin >> a[i];
- sum += a[i];
- cnt0 += a[i] == 0;
- if(a[i] != 0)x.insert(a[i]);
- }
- if (n == 4) {
- bool ok = 1;
- for (auto it : x) {
- if (x.find(-it) == x.end()) {
- ok = 0;
- }
- }
- if (ok) {
- cout << "YES\n";
- }
- else {
- cout << "NO\n";
- }
- }
- else {
- if (x.size() == 2) {
- bool ok = 1;
- for (auto it : x) {
- if (x.find(-it) == x.end()) {
- ok = 0;
- }
- }
- if (ok) {
- cout << "YES\n";
- }
- else {
- cout << "NO\n";
- }
- }
- else if (x.size() <=1) {
- cout << "YES\n";
- }
- else {
- cout << "NO\n";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement