hdu5344MZL's simple problem stl set

来源:互联网 发布:淘宝消费者投诉电话 编辑:程序博客网 时间:2024/06/05 14:09
// 1 x 在set中加x//2 删除集合中的最小元素//3 输出集合的最大元素#include<cstdio>#include<cstring>#include<iostream>#include<set>using namespace std ;const int maxn = 1e6+10 ;multiset<int> ms ;int main(){    int n ;    multiset<int>::iterator it ;    while(~scanf("%d" , &n))    {        ms.clear() ;        while(n--)        {            int op , x ;            scanf("%d" , &op) ;            if(op == 1)            {                scanf("%d" , &x) ;                ms.insert(x) ;            }            else if(op == 2)            {                if(!ms.size())continue ;                ms.erase(ms.begin()) ;            }            else            {                if(!ms.size())puts("0") ;                else                {                    it = ms.end() ;                    it-- ;                    printf("%d\n" , *(it)) ;                }            }        }    }}
0 0
原创粉丝点击