poj 1281 MANAGER

#include<iostream>        //模拟题
#include<set>
using namespace std;
int out[100000],query[100000];
bool first;
int main()
{
int max_cost,len;
while(cin>>max_cost)
{
cin
>>len;
for(int i=0;i<len;++i)
cin
>>query[i];
char ch;
int p=1,x,r=1;
set<int> col;
while(cin>>ch,ch!='e')
{
if(ch=='a')
{
cin
>>x;
col.insert(x);
}
else if(ch=='p')
{
cin
>>p;
}
else if(ch=='r')
{
if(p==1)
{
out[r++]=*col.begin();
col.erase(col.begin());
}
else
{
out[r++]=*(--col.end());
col.erase(
--col.end());
}
}
}
if(!first)
first
=true;
else
cout
<<endl;
for(int i=0;i<len;++i)
cout
<<out[query[i]]<<endl;
}
return 0;
}

  

posted on 2011-07-22 22:30  sysu_mjc  阅读(252)  评论(0编辑  收藏  举报

导航