voidsolve() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } sort(a.begin(), a.end());
int ans = 0; int t = n - 1; for (int i = n - 1; i >= 0; --i) { if (a[i] == a[t]) ans++; else { if (ans % 2 == 0) { ans = 1; t = i; continue; } else { cout << "YES\n"; return; } } } if( ans%2 == 1)cout << "YES\n"; else cout << "NO\n"; }
typedeflonglong LL; typedef pair<int, int> PII; #define int LL constint N = 100000; voidsolve() { int n; cin >> n; vector<int> a(n); for (int i = 0; i < n; i++) { cin >> a[i]; } int sum = 0;
for (int j = 0; j < 2; j++) {
vector<int> b(n + 1);
int maxmad = 0; for (int i = 0; i < n; i++) { sum += a[i]; if (b[a[i]] == 1) { maxmad = max(maxmad, a[i]); } b[a[i]] = 1; a[i] = maxmad; } } for (int i = 0; i < n; i++) { sum += a[i] * (n - i); // 1LL * a[i]* (n-i); } cout << sum << endl; } signedmain() { ios_base::sync_with_stdio(false); cin.tie(NULL); int t; cin >> t; while (t--) { solve(); } return0; } /* 2 2 3 0 2 2 0 0 2 2 1 1 2 0 0 1 2 0 0 0 0 2 2 2 3 1 3 4 4 0 2 2 2 2 3 3 4 0 0 2 2 2 2 3 4 */