Skip to content

Instantly share code, notes, and snippets.

@dudelson
Created January 7, 2017 01:59
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 dudelson/9bdcd6bd1f80f4ff1070623497a3de9a to your computer and use it in GitHub Desktop.
Save dudelson/9bdcd6bd1f80f4ff1070623497a3de9a to your computer and use it in GitHub Desktop.
My solution for UVA 1203
#include <iostream>
#include <queue>
#include <string>
#include <utility>
using namespace std;
#define mp make_pair
int qn, p, k;
string s;
priority_queue< pair< pair<int, int>, int> > q;
int main() {
while(true) {
cin >> s;
if(s == "#") break;
cin >> qn >> p;
q.push(mp(mp(-p, -qn), -p));
}
cin >> k;
while(k--) {
auto t = q.top();q.pop();
cout << -t.first.second << '\n';
t.first.first += t.second;
q.push(t);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment