Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- #include <vector>
- using namespace std;
- class Elem{
- public:
- int x;
- bool operator()(const Elem & el ) const{
- return x < el.x;
- }
- };
- /*typedef struct{
- int x;
- }Elem;
- */
- bool operator()(Elem a, Elem b)
- {
- return a.x < b.x;
- }
- int main()
- {
- vector<int> v;
- priority_queue <Elem, cmp> q;
- Elem e;
- int i, n, y;
- cin >> n;
- for(i = 1; i <= n; ++i)
- {
- cin >> y;
- e.x = y;
- q.push(e);
- }
- for(i = 1; i <= n; ++i)
- {
- e = q.top();
- v.push_back(e.x);
- q.pop();
- }
- for(i = 1; i <= n; ++i)
- cout << v[i]<<" ";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement