fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. int x,sum=0,n=0;
  7. cin >> x;
  8. int c[x];
  9. for(int i=0 ; i < x ; i++)
  10. {
  11. cin >> c[i];
  12. c[i] -= 1;
  13. if(i % 2 == 0)
  14. {
  15. sum += c[i];
  16. n += 1;
  17. }
  18. else
  19. {
  20. i -= 1;
  21. }
  22. }
  23. cout << n << " " << sum << endl;
  24. return 0;
  25. }
Time limit exceeded #stdin #stdout 5s 15232KB
stdin
8
1 3 5 7 11 13 17 19
stdout
Standard output is empty