fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n, m = 0;
  6. double k = 0;
  7. cin >> n;
  8. double *x = new double[n];
  9. for (int i = 0; i<n; i++)
  10. cin >> x[i];
  11. for (int i = 0; i<n; i++) {
  12. if (x[i]<0){
  13. m++;
  14. k += x[i];
  15. }
  16. }
  17. cout.precision(2);
  18. cout << m << " " << fixed << k;
  19. return 0;
  20. }
Success #stdin #stdout 0s 15232KB
stdin
3
-1.992345 -5.334224 9
stdout
2 -7.33