ada

by adee on March 9th, 2010
No notes
Syntax: C++
Show lines - Hide lines - Show in textbox - Download
#include<cstdio>
#include<queue>
using namespace std;
int main()
{
    int t,k,m,o,w=0;
    pair<int,int> z;
    priority_queue<pair<int,int> > p;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d%d%d",&o,&m,&k);
        k*=-1;
        if(o==1)
            p.push(make_pair(m,k));
 
        else if(o==0)
        {   
            z=make_pair(m,k);
            if(!p.empty())
            {
                if(p.top()>z)
                {
                    w++;
                    p.push(z);
                }
 
                else if(p.top()<z)
                p.pop();
            }
        }
 
 
    }
    printf("%d",w);
 
}
 

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS