Guest User

Untitled

a guest
Apr 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include<fstream>
  2. #include<iostream>
  3. #include<iomanip>
  4. #include<set>
  5. using namespace std;
  6.  
  7. //ifstream f("1306.in");
  8.  
  9. struct cmp
  10. { bool operator()(unsigned int a, unsigned int b)
  11. { return a > b;
  12. }
  13. };
  14.  
  15. int N;
  16. multiset<unsigned int, cmp> h;
  17.  
  18. int main()
  19. { int i, j;
  20. double rez;
  21.  
  22. cin>>N;
  23. for(i = 1; i <= N; i++)
  24. { cin>>j;
  25. if(i > N / 2 + 1)
  26. { if(j < *h.begin())
  27. h.erase(h.begin()), h.insert(j);
  28. }else h.insert(j);
  29. }
  30.  
  31. if(N % 2) rez = *h.begin();
  32. else
  33. { rez = *h.begin();
  34. h.erase(h.begin());
  35. rez += *h.begin();
  36. rez /= 2;
  37. }
  38.  
  39. cout.precision(1);
  40. cout<<fixed<<rez<<'\n';
  41.  
  42. //f.close();
  43. return 0;
  44. }
Add Comment
Please, Sign In to add comment