Skip to content

Instantly share code, notes, and snippets.

@frmsaul
Created March 1, 2015 05:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save frmsaul/7faf51d62ef6639f2492 to your computer and use it in GitHub Desktop.
Save frmsaul/7faf51d62ef6639f2492 to your computer and use it in GitHub Desktop.
// your_objects is vector of pair<string, vector<int> >
// PQ is your priority_queue
int vector_counter = 0;
for(int i = 0; i < 10; i++){
PQ.push(your_pairs[vector_counter]);
vector_counter++;
}
while(vector_counter < your_objects.size()){
PQ.push(your_pairs[vector_counter]);
PQ.pop();
vector_counter++;
}
//At the end of the day, PQ is gonna have the 10 "highest" elements
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment