Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void solve()
- {
- map<int,map<int,int>,greater<>>m;//price
- map<int,int>m2;//queue
- int q;cin>>q;
- int k=1;
- while(q--)
- {
- int a;cin>>a;
- if(a==1)
- {
- int price;cin>>price;
- m2[k]=price;
- m[price][k]=0;
- k++;
- }
- else if(a==2)
- {
- cout<<m2.begin()->first<<" ";
- m[m2.begin()->second].erase(m2.begin()->first);
- m2.erase(m2.begin());
- }
- else
- {
- int z=m.begin()->first;
- int l=m[z].begin()->first;
- cout<<l<<" ";
- m2.erase(m[z].begin()->first);
- m[z].erase(m[z].begin());
- }
- }
- }
- int main()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- int t;t=1;
- //cin>>t;
- while(t--)
- {
- solve();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement