typedeflonglong LL; constint N = 2e5 + 10; LL arr[N]; voidsolve(){ int num; cin >> num; vector<LL> vec; LL maxodd = 0; for (int i = 0; i < num; i++) { cin >> arr[i]; }
for (int i = 0; i < num; i++) //统计奇数偶数 { if (arr[i] % 2 == 0) vec.push_back(arr[i]); if (arr[i] % 2 == 1 && arr[i] > maxodd) maxodd = arr[i]; } if (vec.size() == num || vec.empty()) //全为奇数或者偶数 { cout << 0 << endl; return; } int ans = vec.size(); sort(vec.begin(), vec.end()); int flag = 0; for (auto x : vec) { if (x < maxodd) maxodd = x + maxodd; else flag = 1; //择任意奇数与最大的偶数操作两次,可以造出一个比任何偶数都大的奇数,再使用该奇数操作即可 }
cout << ans + flag << "\n"; }
intmain(){ int n; cin >> n; while (n--) { solve(); } }