fork download
  1. #include <iostream>
  2. #include<algorithm>
  3. #include<vector>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. // your code goes here
  9. int n,a;
  10. vector <int> list;
  11. cin>>n;
  12. while(n--)
  13. {
  14. cin>>a;
  15. list.push_back(a);
  16. sort(list.begin(),list.end());
  17. int s = list.size();
  18. if(s%2!=0)
  19. cout<<list[s/2]<<endl;
  20. else
  21. cout<<(list[(s/2)-1]+list[s/2])/2<<endl;
  22.  
  23. }
  24.  
  25.  
  26. return 0;
  27. }
Success #stdin #stdout 0s 15232KB
stdin
4
5
15
1 
3
stdout
5
10
5
4