Advertisement
_no0B

Untitled

Jul 23rd, 2021
1,140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.66 KB | None | 0 0
  1.  
  2.  
  3. #include<bits/stdc++.h>
  4. #define ll long long
  5. #define fastio ios_base::sync_with_stdio(false),cin.tie(NULL)
  6. #define N ((int)1e6 + 9)
  7. #define endl "\n"
  8.  
  9. using namespace std;
  10.  
  11.  
  12. /*fast io
  13. ios_base::sync_with_stdio(false);
  14. cin.tie(NULL);
  15. */
  16.  
  17.  
  18. /// priority queue
  19. int main()
  20. {
  21. //    fastio;
  22.  
  23.     int n;
  24.     cin>>n;
  25.     priority_queue < int > pqq;
  26.  
  27.     while(n > 0){
  28.         n--;
  29.         int a;
  30.         cin>>a;
  31.         pqq.push(-a); /// O ( logn )
  32.     }
  33.  
  34.     while(pqq.empty() == 0){
  35.         int a = pqq.top(); /// O ( logn ) /// log ( 1e6 ) = 20
  36.         cout<<a<<" "<<-a<<endl;
  37.         pqq.pop(); /// O ( logn )
  38.     }
  39.  
  40.     return 0;
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement