Can you restore the same group of numbers from the beginning? If so, you can make several passes over the output: start by finding the highest value, restart the generator, find the largest number less than this, restart the generator and repeat this until you get your result.
It will be a real productivity killer because you have many numbers and many passes will be required - but from the point of view of memory you will only need to save 2 elements (current maximum and โlimitโ), the number that you found during the last pass) and passage counter.
You can speed it up by using the priority turn to find the M largest elements (by selecting some M that you can store in memory), allowing you to reduce the number of passes needed for N / M.
If you need to find, say, the 10th largest item in a list of 15 numbers, you could save time by working the other way around. Since this is the 10th largest element, this means that there are 15-10 = 5 elements smaller than that element, so instead you can search for the 6th smallest element.
source share