fork download
  1. #include <iostream>
  2. #include <algorithm>
  3.  
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. long long numbers[10005];
  10. int i=0;
  11. bool two_times=false;
  12. int temp;
  13. while(cin >> temp)
  14. {
  15. numbers[i]=temp;
  16. if(!two_times)
  17. {
  18. nth_element(numbers,(numbers+i/2),numbers+i+1);
  19. cout << numbers[i/2] << endl;
  20. }
  21. else
  22. {
  23. nth_element(numbers,numbers+i/2,numbers+i+1);
  24. nth_element(numbers,numbers+i/2+1, numbers+i+1);
  25. int ret= numbers[i/2] + numbers[i/2+1];
  26. ret/=2;
  27. cout << ret << endl;
  28. }
  29.  
  30.  
  31. i++;
  32. two_times=!two_times;
  33. }
  34. }
Success #stdin #stdout 0s 3304KB
stdin
1
1
2
2
8
8
9
9
5
6
stdout
1
1
1
1
2
1
2
5
5
5