fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5.  
  6. long long sum = 0, kM = 0, km = 0, n = 0;
  7. int mass = 0, M = 0, m = 0;
  8.  
  9. while(cin >> mass){
  10. if(n == 0){
  11. M = mass;
  12. m = mass;
  13. km = 1;
  14. kM = 1;
  15. }
  16. else{
  17. if(mass > M){
  18. M = mass;
  19. kM = 1;
  20. }
  21. else if(mass == M) kM++;
  22.  
  23. if(mass < m){
  24. m = mass;
  25. km = 1;
  26. }
  27. else if(mass == m) km++;
  28. }
  29. sum += mass;
  30. n++;
  31. }
  32. n == kM + km? cout << 0 : cout << (2*(sum-kM*M-km*m)+n-kM-km)/(2*(n-kM-km));
  33. return 0;
  34. }
Success #stdin #stdout 0s 15232KB
stdin
40   23 27
  59 68 23    84   27
53 46 
stdout
46