Advertisement
LEGEND2004

set multiset

Mar 4th, 2024 (edited)
533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.91 KB | None | 0 0
  1. #pragma GCC optimize("O3")
  2. #include <bits/stdc++.h>
  3. using namespace std;
  4.  
  5. #define int long long
  6. #define fastio ios_base::sync_with_stdio(0); cin.tie(0)
  7.  
  8. signed main()
  9. {
  10.     fastio;
  11.    
  12.     int x;
  13.     multiset<int> ms;
  14.     multiset<int>::iterator it;
  15.    
  16.     ms.size();
  17.     ms.empty();
  18.     ms.insert(x); // log n
  19.     *ms.begin(); // min
  20.     *ms.rbegin(); // max
  21.     ms.count(x); // x-in sayi
  22.     ms.erase(x); // butun x lari sil
  23.     if(ms.find(x) != ms.end()) // eger varsa ms.count(x)
  24.         ms.erase(ms.find(x)); // bir dene x sil
  25.  
  26.     ms.lower_bound(x); // x dan boyuk beraber ilk eded
  27.     ms.upper_bound(x); // x dan boyuk ilk eded
  28.    
  29.     for(auto it = ms.begin(); it != ms.end(); it++){
  30.         cout << *it << " ";
  31.     }
  32.    
  33.     for(auto i : ms){
  34.         cout << i << " ";
  35.     }
  36.    
  37.     set<int> s;
  38.     // her elementden 1 dene saxlayir
  39.     // 7 4 5 5 6 2 2
  40.     // 2 4 5 6 7
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement