PTA 7-7 Windows消息队列

网友投稿 785 2022-11-28

PTA 7-7 Windows消息队列

PTA 7-7 Windows消息队列

#include #include #include #include #include #include #include using namespace std;const int maxn = 1e5 + 10;struct Data { int x, id; Data(int xx, int i) : x(xx), id(i) {} bool operator < (const Data &temp) const { return x > temp.x; }};char s[20], str[maxn][20];int main() { int n, x, cnt = 0; priority_queue q; scanf("%d", &n); for (int i = 1; i <= n; i++) { scanf("%s", s); if (s[0] == 'P') { scanf("%s%d", str[++cnt], &x); q.push(Data(x, cnt)); } else { if (q.empty()) printf("EMPTY QUEUE!\n"); else { Data d = q-(); q.pop(); printf("%s\n", str[d.id]); } } } return 0;}

版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:7-20 奥运排行榜
下一篇:UVALive - 7008 Tactical Multiple Defense System——二分图最大匹配
相关文章

 发表评论

暂时没有评论,来抢沙发吧~