#include <iostream>
#include <vector>
#include <queue>
#include <functional>
typedef std::pair<int, int> parInts;
bool comparador (parInts ponto1, parInts ponto2){
if (ponto1.first == ponto2.first){
return ponto1.second > ponto2.second;
}
else {
return ponto1.first > ponto2.first;
}
}
int main () {
std::priority_queue<parInts, std::vector<parInts>, std::function<bool(parInts, parInts)>> fila(comparador);
fila.push(std::make_pair(5, 1));
fila.push(std::make_pair(3, 2));
fila.push(std::make_pair(6, 3));
fila.push(std::make_pair(3, 4));
while (!fila.empty()){
std::pair<int, int> ponto = fila.top();
std::cout << ponto.first << " " << ponto.second << std::endl;
fila.pop();
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8cXVldWU+CiNpbmNsdWRlIDxmdW5jdGlvbmFsPgoKdHlwZWRlZiBzdGQ6OnBhaXI8aW50LCBpbnQ+IHBhckludHM7Cgpib29sIGNvbXBhcmFkb3IgKHBhckludHMgcG9udG8xLCBwYXJJbnRzIHBvbnRvMil7CiAgICBpZiAocG9udG8xLmZpcnN0ID09IHBvbnRvMi5maXJzdCl7CiAgICAgICAgcmV0dXJuIHBvbnRvMS5zZWNvbmQgPiBwb250bzIuc2Vjb25kOwogICAgfQogICAgZWxzZSB7CiAgICAgICAgcmV0dXJuIHBvbnRvMS5maXJzdCA+IHBvbnRvMi5maXJzdDsKICAgIH0KfQoKaW50IG1haW4gKCkgewogICAgc3RkOjpwcmlvcml0eV9xdWV1ZTxwYXJJbnRzLCBzdGQ6OnZlY3RvcjxwYXJJbnRzPiwgc3RkOjpmdW5jdGlvbjxib29sKHBhckludHMsIHBhckludHMpPj4gZmlsYShjb21wYXJhZG9yKTsKCiAgICBmaWxhLnB1c2goc3RkOjptYWtlX3BhaXIoNSwgMSkpOwogICAgZmlsYS5wdXNoKHN0ZDo6bWFrZV9wYWlyKDMsIDIpKTsKICAgIGZpbGEucHVzaChzdGQ6Om1ha2VfcGFpcig2LCAzKSk7CiAgICBmaWxhLnB1c2goc3RkOjptYWtlX3BhaXIoMywgNCkpOwoKICAgIHdoaWxlICghZmlsYS5lbXB0eSgpKXsKICAgICAgICBzdGQ6OnBhaXI8aW50LCBpbnQ+IHBvbnRvID0gZmlsYS50b3AoKTsKICAgICAgICBzdGQ6OmNvdXQgPDwgcG9udG8uZmlyc3QgPDwgIiAiIDw8IHBvbnRvLnNlY29uZCA8PCBzdGQ6OmVuZGw7CiAgICAgICAgZmlsYS5wb3AoKTsKICAgIH0KCiAgICByZXR1cm4gMDsKfQo=