ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

¶þ²æ¶Ñ¶Ô½á¹¹ÌåʹÓÃÓÅÏȶÓÁÐ
2013-11-20 14:24:09 À´Ô´: ×÷Õß: ¡¾´ó ÖРС¡¿ ä¯ÀÀ:138´Î
Tags£º½á¹¹ ʹÓà ÓÅÏÈ ¶ÓÁÐ
    ZOJ 2724 Windows Message Queue£¨¶Ô½á¹¹ÌåʹÓÃÓÅÏȶÓÁУ©
    /*
    * ZOJ_2724.cpp
    *
    *  Created on: 2013Äê11ÔÂ7ÈÕ
    *      Author: Administrator
    */
    #include <iostream>
    #include <cstdio>
    #include <cstring>
    #include <queue>
    using namespace std;
    struct MES {
    char str ;
    int mes;
    int p;
    int id;
    bool operator<£¨ const MES& b£©const {//ÌØ±ðҪעÒâÕâÖÖд·¨¡­
    if £¨p != b.p£© {
    return p > b.p;
    }
    return id > b.id;
    }
    };
    int main£¨£© {
    char s[26];
    priority_queue<MES> q;//¶Ô½á¹¹ÌåʹÓÃÓÅÏȶÓÁÐ
    MES tmp;
    while £¨scanf£¨"%s", s£© != EOF£© {
    int index = 0;
    if £¨strcmp£¨s, "PUT"£© == 0£© {
    scanf£¨"%s %d %d", tmp.str, &tmp.mes, &tmp.p£©£»
    tmp.id = index++;
    q.push£¨tmp£©£»
    } else {
    if £¨q.empty£¨£©£© {
    printf£¨"EMPTY QUEUE!\n"£©£»
    } else {
    tmp = q.top£¨£©£»
    q.pop£¨£©£»
    printf£¨"%s %d\n", tmp.str, tmp.mes£©£»
    }
    }
    }
    return 0;
    }

¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
·ÖÏíµ½: 
ÉÏһƪ£ºÇ°Ðò±éÀú¶þ²æÊ÷µÝ¹é½â·¨ ÏÂһƪ£ºÉ¡±ø½µÂäµÄ¾«×¼±à³ÌʵÀý

ÆÀÂÛ

ÕÊ¡¡¡¡ºÅ: ÃÜÂë: (ÐÂÓû§×¢²á)
Ñé Ö¤ Âë:
±í¡¡¡¡Çé:
ÄÚ¡¡¡¡ÈÝ:

¡¤Linuxϵͳ¼ò½é (2025-12-25 21:55:25)
¡¤Linux°²×°MySQL¹ý³Ì (2025-12-25 21:55:22)
¡¤Linuxϵͳ°²×°½Ì³Ì£¨ (2025-12-25 21:55:20)
¡¤HTTP Åc HTTPS µÄ²î„ (2025-12-25 21:19:45)
¡¤ÍøÕ¾°²È«±ØÐ޿ΣºÍ¼ (2025-12-25 21:19:42)