fork(2) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define fast_io ios::sync_with_stdio(false); cin.tie(NULL)
  5. #define int long long
  6.  
  7. void solve() {
  8. int n;
  9. cin >> n;
  10.  
  11. vector<int> a(n);
  12. int sum = 0;
  13.  
  14. for (int i = 0; i < n; i++) {
  15. cin >> a[i];
  16. if (a[i] < 2 * (i + 1)) a[i] = 2 * (i + 1);
  17. sum += a[i];
  18. }
  19.  
  20. cout << sum << "\n";
  21. }
  22.  
  23. int32_t main() {
  24. fast_io;
  25. int t;
  26. cin >> t;
  27. while (t--) solve();
  28. return 0;
  29. }
  30.  
Success #stdin #stdout 0.01s 5276KB
stdin
4
3
2 5 1
2
4 4
4
1 3 2 1
5
3 2 0 9 10
stdout
13
8
20
32