Pagini recente » Cod sursa (job #8554) | Diferente pentru utilizator/dornescuvlad intre reviziile 102 si 53 | Rating Adrian Har (adihar) | Cod sursa (job #1173653) | Cod sursa (job #568032)
Cod sursa(job #568032)
#include <stdio.h>
#include <queue>
#include <vector>
#include <bitset>
using namespace std ;
#define dim 200100
#define mp make_pair
#define fs first
#define sc second
bitset <dim > viz ;
int c;
struct cmp
{
bool operator() ( const pair <int,int> &a , const pair <int , int > &b ) const
{
return a>b;
}
};
priority_queue <pair <int , int > , vector < pair < int , int > > , cmp > q;
void solve ()
{
int n,y,x;
scanf("%d",&n);
for(int i=1 ; i<=n;i++)
{
scanf("%d",&y ) ;
if ( y == 1 )
{
scanf("%d",&x);
q.push(mp (x, ++c ));
// viz[x] = 0;
}
if ( y==2 )
{
scanf("%d",&x ) ;
viz[x] = 1;
}
if ( y==3 )
{
while ( viz [ q.top().sc ] == 1 )
q.pop();
printf("%d\n",q.top().fs );
}
}
}
int main ()
{
freopen("heapuri.in","r",stdin);
freopen("heapuri.out","w",stdout);
solve () ;
return 0;
}