fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. vector<ll> v;
  5. int32_t main() {
  6. // your code goes here
  7. ios_base::sync_with_stdio(false);
  8. cin.tie(NULL);
  9. ll q;
  10. cin>>q;
  11. while(q--){
  12. ll a;
  13. cin>>a;
  14. if(a==1) {
  15. ll b;
  16. cin>>b;
  17.  
  18. v.push_back(b);
  19. }
  20.  
  21. else if(a==2){
  22.  
  23. if(v.size()>=2) {
  24. cout<<v[0]<<"\n";
  25. v.erase(v.begin());
  26.  
  27. }
  28.  
  29. /*
  30.   for(ll i=0;i<v.size();i++)
  31.   cout<<v[i]<<" ";
  32.   cout<<"\n";
  33.   */
  34. }
  35. else {
  36. sort(v.begin(),v.end());
  37. }
  38. }
  39.  
  40.  
  41. return 0;
  42. }
Success #stdin #stdout 0.01s 5492KB
stdin
5
1 2 
2 
1 3 
3 
2
stdout
2