fork download
  1. #include <iostream>
  2. #include <iomanip>
  3. using namespace std;
  4.  
  5. int main() {
  6. int n;
  7. cin >> n;
  8. int num = 0;
  9. double sum = 0;
  10. for (int i = 1; i <= n; i++) {
  11. double a;
  12. cin >> a;
  13. if ((i%3) == 0 and a > 0) {
  14. num++;
  15. sum += a;
  16. }
  17. }
  18. cout << num << " " << fixed << setprecision(2) << sum << endl;
  19. return 0;
  20. }
Success #stdin #stdout 0s 15232KB
stdin
12
0 15.3 -1 144 0.333 17.5 -69 456 2.5 0 3 13
stdout
3 33.00