#include <iostream>
#include <queue>
using namespace std;
void showpq(
priority_queue<int, vector<int>, greater<int> > g)
{
while (!g.empty()) {
cout << ' ' << g.top();
g.pop();
}
cout << '\n';
}
void showArray(int* arr, int n)
{
for (int i = 0; i < n; i++) {
cout << arr[i] << ' ';
}
cout << endl;
}
int main()
{
int arr[6] = { 10, 2, 4, 8, 6, 4 };
priority_queue<int, vector<int>, greater<int> > gquiz(
arr, arr + 6);
cout << "Array: ";
showArray(arr, 6);
cout << "Priority Queue : ";
showpq(gquiz);
return 0;
}
CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHF1ZXVlPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdm9pZCBzaG93cHEoCglwcmlvcml0eV9xdWV1ZTxpbnQsIHZlY3RvcjxpbnQ+LCBncmVhdGVyPGludD4gPiBnKQp7Cgl3aGlsZSAoIWcuZW1wdHkoKSkgewoJCWNvdXQgPDwgJyAnIDw8IGcudG9wKCk7CgkJZy5wb3AoKTsKCX0KCWNvdXQgPDwgJ1xuJzsKfQoKdm9pZCBzaG93QXJyYXkoaW50KiBhcnIsIGludCBuKQp7Cglmb3IgKGludCBpID0gMDsgaSA8IG47IGkrKykgewoJCWNvdXQgPDwgYXJyW2ldIDw8ICcgJzsKCX0KCWNvdXQgPDwgZW5kbDsKfQoKCmludCBtYWluKCkKewoJaW50IGFycls2XSA9IHsgMTAsIDIsIDQsIDgsIDYsIDQgfTsKCXByaW9yaXR5X3F1ZXVlPGludCwgdmVjdG9yPGludD4sIGdyZWF0ZXI8aW50PiA+IGdxdWl6KAoJCWFyciwgYXJyICsgNik7CgoJY291dCA8PCAiQXJyYXk6ICI7CglzaG93QXJyYXkoYXJyLCA2KTsKCgljb3V0IDw8ICJQcmlvcml0eSBRdWV1ZSA6ICI7CglzaG93cHEoZ3F1aXopOwoKCXJldHVybiAwOwp9Cg==