HDU 1873 is waiting for medical treatment

Source: Internet
Author: User

Priority queue, water question.

Three doctors should have three priority queues.

Priority queue should be initialized for multiple groups of data

#include<cstdio>#include<cstring>#include<string>#include<queue>#include<algorithm>#include<map>#include<stack>#include<iostream>#include<list>#include<set>#include<vector>#include<cmath>#define INF 0x7fffffff#define eps 1e-8#define LL long long#define PI 3.141592654#define CLR(a,b) memset(a,b,sizeof(a))#define FOR(i,a,b) for(int i=a;i<b;i++)#define FOR0(i,a,b) for(int i=a;i>=b;i--)#define pb push_back#define debug puts("==fuck==")#define acfun std::ios::sync_with_stdio(false)#define SIZE 20+10using namespace std;struct lx{    int value;    int ID;    friend bool operator <( lx a,lx b)    {        if(a.value==b.value)            return a.ID>b.ID;        return a.value<b.value;    }};int main(){    int t;    priority_queue<lx> q[4];    int Id=1;    while(scanf("%d",&t)!=EOF)    {        char head[11];        scanf("%s",head);        if(strcmp(head,"OUT")==0)        {            int value;            scanf("%d",&value);            if(q[value].empty())                puts("EMPTY");            else            {                lx now;                now=q[value].top();                q[value].pop();                printf("%d\n",now.ID);            }        }        else if(strcmp(head,"IN")==0)        {            int value;            lx now;            scanf("%d%d",&value,&now.value);            now.ID=Id++;            q[value].push(now);        }        t--;        if(t==0)        {            FOR(i,1,4)            {                while(!q[i].empty())                    q[i].pop();            }            Id=1;        }    }}


HDU 1873 is waiting for medical treatment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.