title: how to track max/min of fifo query
body: <p>I have fifo query where I put and eject doubles.
  After each update I need max and min values. I don't need position (or index) of these values in query.
  How to do that effectively? log(N) or probably even O(1)?</p>
  
  <p>upd: found this <a href="https://stackoverflow.com/questions/4802038/implement-a-queue-in-which-push-rear-pop-front-and-get-min-are-all-consta">Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations</a></p>