--山东省第六届省赛--B

Map的使用,掌握基础STL的使用。

#include<stdio.h>
#include<string.h>
#include<map>
#include<algorithm>
using namespace std;
int main(){
    
    int t;
    scanf("%d",&t);
    while(t--){
        map<int,int>m1;
        map<int,int>m2;
        
        int n;
        
        scanf("%d",&n);
        
        while(n--){
        
            int x;
            
            char a[2];
            scanf("%s",a);
            if(a[0] == 'b'){
                scanf("%d",&x);
                m1[x]++;
                if(m1[x] == 1)m2[x] = 1;
                if(m1[x] != 1)m2.erase(x);
            
            }
            else if(a[0] == 'c'){
                
                scanf("%d",&x);
                m1[x]--;
                if(m1[x] == 1)m2[x] = 1;
                if(m1[x] != 1)m2.erase(x);
                
            }
            else {
                if(m2.empty())puts("none");
                else printf("%d\n",m2.begin()->first);
            }
            
        }
    }
    
    
} 

 

posted @ 2015-05-15 20:44  袁汉春  阅读(132)  评论(0编辑  收藏  举报