fork download
  1. #include <iostream>
  2. #include <map>
  3. using namespace std;
  4.  
  5. int main() {
  6. int count = 0, elem;
  7. unsigned long long sum = 0;
  8. map<int, int> MAP;
  9. while (cin >> elem) {
  10. if (MAP.find(elem) == MAP.end()) MAP[elem] = 1;
  11. else MAP[elem]++;
  12. sum += elem;
  13. count++;
  14. }
  15. sum -= MAP.begin()->first * MAP.begin()->second + (--MAP.end())->first * (--MAP.end())->second;
  16. count -= MAP.begin()->second + (--MAP.end())->second;
  17. cout << sum / count + 1 * (sum % count > count / 2);
  18. return 0;
  19. }
Success #stdin #stdout 0s 15240KB
stdin
40   23 27
  59 68 23    84   27
53 46   
stdout
46