fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define int long long
  5.  
  6. const int oo = 1e5 + 3;
  7.  
  8. int n;
  9. int a[oo];
  10.  
  11. void solve() {
  12. cin >> n;
  13. for (int i = 1; i <= n; i++) {
  14. cin >> a[i];
  15. }
  16.  
  17. int sumOdd = 0;
  18. int sumEven = 0;
  19. int odd = 0;
  20. for (int i = 1; i <= n; i++) {
  21. sumOdd += (a[i] % 2) * a[i];
  22. sumEven += (1 - a[i] % 2) * a[i];
  23.  
  24. odd += (a[i] & 1);
  25.  
  26. int cost = 0;
  27.  
  28. if (i > 1) {
  29. cost = (odd / 3) + (odd % 3 == 1);
  30. }
  31.  
  32. cout << sumOdd - cost + sumEven <<" ";
  33. }
  34.  
  35. cout << "\n";
  36. }
  37.  
  38. signed main() {
  39.  
  40. int t;
  41. cin >> t;
  42. while (t--) {
  43. solve();
  44. }
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0s 544KB
stdin
4
1
31
6
6 3 7 2 5 4
3
3 10 11
5
7 13 11 19 1
stdout
31 
6 8 16 18 22 26 
3 12 24 
7 20 30 48 50