码迷,mamicode.com
首页 > 其他好文 > 详细

hdu 5349 MZL's simple problem(multiset)

时间:2015-08-04 23:00:22      阅读:155      评论:0      收藏:0      [点我收藏+]

标签:

代码:
#include<set>
#include<cstdio>
using namespace std;

multiset<int> st;

int main()
{
    int n;
    multiset<int>::iterator it;
    while(scanf("%d",&n)==1)
    {
        st.clear();
        int k,num;
        for(int i=0; i<n; i++)
        {
            scanf("%d",&k);
            if(k==1)
            {
                scanf("%d",&num);
                st.insert(num);
            }
            else if(k==2)
            {

                if(st.size()>0)
                {
                    it=st.begin();
                    st.erase(*it);
                }
            }
            else
            {
                if(st.size()>0)
                {
                    it=st.end();
                    it--;
                    printf("%d\n",*it);
                }
                else
                    printf("0\n");
            }
        }
    }
    return 0;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

hdu 5349 MZL's simple problem(multiset)

标签:

原文地址:http://blog.csdn.net/xky1306102chenhong/article/details/47283169

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!