fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef unsigned long long ll;
  5. const int MAX_N = 5e4+5;
  6.  
  7. int main() {
  8. ios_base::sync_with_stdio(0);
  9. cin.tie(0);
  10.  
  11. // domyslnie pierwszy element do wyjecia z kolejki to
  12. // ten o najwiekszym priorytecie (w przypadku int to po prostu
  13. // najwieksza liczba)
  14. // wbudowany komparator greater zmienia sposob porywnywania,
  15. // bysmy mogli wyciagac elementy od najmniejszego
  16.  
  17. /*priority_queue<int, vector<int>, greater<int>> pq;
  18.  
  19.   pq.push(4);
  20.   pq.push(3);
  21.   pq.push(5);
  22.  
  23.   while (!pq.empty()) {
  24.   cout << pq.top() << '\n';
  25.   pq.pop();
  26.   }*/
  27.  
  28. multiset<int> S;
  29. S.insert(5);
  30. S.insert(5);
  31. S.insert(5);
  32. S.insert(3);
  33. S.insert(4);
  34.  
  35. while (!S.empty()) {
  36. cout << *S.begin() << '\n';
  37. S.erase(S.begin());
  38. }
  39.  
  40.  
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
3
4
5
5
5