zoukankan      html  css  js  c++  java
  • hdu 4557

    #include<stdio.h>
    #include<queue>
    #include<iostream>
    #define N 1100
    using namespace std;
    struct node {
    char s[20];
    int  power,num;
    friend bool operator<(node a,node b) {
    if(a.power!=b.power)
            return  a.power>b.power;
    return a.num>b.num;
    }
    };
    int main() {
    int t,n,m,i,j,k,count=0,h,flag;
    char str[20];
    scanf("%d",&t);
    while(t--) {
    scanf("%d",&n);
    priority_queue<node>q,q1;
    node p;k=0;h=0;
    printf("Case #%d: ",++count);
    while(n--) {
    scanf("%s",str);
    if(str[0]=='A') {
    scanf("%s%d",str,&m);
     strcpy(p.s,str);
     p.power=m;
     p.num=++k;
     h++;
     q.push(p);
     printf("%d ",h);
    }
    else
    if(str[0]=='F') {
    flag=0;
    scanf("%d",&m);
    while(!q.empty()) {
    p=q.top();
    if(p.power>=m) {
    printf("%s ",p.s);
    flag=1;
    h--;
    q.pop();
    break;
    }
    q.pop();
    q1.push(p);
    }
    if(flag==0) 
    printf("WAIT... ");
    while(!q1.empty()) {
    q.push(q1.top());
    q1.pop();
    }
    }
    }
    }
    return 0;
    }




  • 相关阅读:
    ACM士兵排队
    ACM两个士兵打牌
    ACM平衡的括号
    ACM复合词
    ACM第二次比赛( C )
    ACM比赛(第二次A)
    ACM比赛(进制转换)
    ACM比赛(11462 Age Sort)
    ACM比赛
    hdu 1241 Oil Deposits(DFS求连通块)
  • 原文地址:https://www.cnblogs.com/thefirstfeeling/p/4410943.html
Copyright © 2011-2022 走看看