Guest User

Untitled

a guest
Jun 20th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. #include <iomanip>
  4. using namespace std;
  5.  
  6. int niz[10020];
  7.  
  8. int main()
  9. {
  10. freopen("puberaks.10.in","r",stdin);
  11. int n,s1,s2,s,a;
  12. s1=0;
  13. s2=0;
  14. s=0;
  15. a=1;
  16. double izlaz=-151.1581;
  17. cin >> n ;
  18. for (int i = 0; i < n; i++)
  19. {
  20. cin >> niz[i];
  21. s+=niz[i];
  22. }
  23. sort(niz,niz+n);
  24. a=0;
  25. for (int i = 0; i < n-1 ; i++)
  26. {
  27. a++;
  28. s1=s1+niz[i];
  29. s2=s-s1;
  30. double x,y,z,z1;
  31. x=s1/(a);
  32. y=s2/(n-a);
  33. if (x>=y)z=x-y;
  34. else z=y-x;
  35. izlaz=max(izlaz,z);
  36. }
  37. printf("%.2lf", izlaz);
  38. //cout.setf(ios::fixed,ios::floatfield);
  39. //cout.precision(2);
  40. //cout << izlaz << endl;
  41. return 0;
  42. }
Add Comment
Please, Sign In to add comment