首页 > 其他 > 详细

hdu 5349 MZL's simple problem(multiset)

时间:2015-08-04 22:58:43      阅读:229      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!