fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args)
  7. {
  8.  
  9. int m = 0;
  10. double k = 0;
  11. Scanner input = new Scanner(System.in);
  12. int n = input.nextInt();
  13. double x[] = new double [n];
  14. for (int i = 0; i<n; i++)
  15. {
  16. x[i] = input.nextDouble();
  17. }
  18. for (int i = 0; i<n; i++)
  19. {
  20. if (x[i]<0)
  21. {
  22. m++;
  23. k += x[i];
  24. }
  25. }
  26. System.out.print(m + " " + String.format("%.3g%n", k));
  27. }
  28. }
Success #stdin #stdout 0.08s 2184192KB
stdin
3
-1.992345 -5.334224 9

stdout
2 -7.33