Advertisement
_no0B

set.cpp

Mar 10th, 2021
1,225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.56 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #define N ((int)1e6 + 5)
  3.  
  4. using namespace std;
  5.  
  6.  
  7.  
  8. int main()
  9. {
  10.     set < int > name;
  11.     int n;
  12.     cin>>n;
  13.     for(int i = 1 ; i<=n; i++){
  14.         int a;
  15.         cin>>a;
  16.         name.insert(a); /// logn
  17.     }
  18.     set < int > :: iterator itt = name.end();
  19.     itt--;
  20.     while(1){
  21.         cout<<*itt<<" ";
  22.         if(itt == name.begin()) break;
  23.         itt--;
  24.     }
  25.     cout<<endl;
  26.     name.erase(-1); /// logn
  27.     for(itt = name.begin() ; itt != name.end() ; itt++) cout<<*itt<<" ";
  28.     cout<<endl;
  29.     return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement