Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int main(){
- string str;
- int x , maxx = 0;
- map<int , stack<int> > s;
- map<int , int> say;
- while(cin >> str){
- if(str == "push"){
- cin >> x;
- say[x]++;
- s[say[x]].push(x);
- maxx = max(maxx , say[x]);
- continue;
- }
- say[s[maxx].top()]--;
- cout << s[maxx].top() << endl;
- s[maxx].pop();
- while(s[maxx].empty()){
- maxx--;
- if(!maxx)
- break;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement