ZOJ 3230 Solving the Problems
来源:互联网 发布:围棋软件形势判断 编辑:程序博客网 时间:2024/04/30 11:45
优先队列。
按a和b为关键字分别建立优先队列即可。
#include <cstdio>#include <cstring>#include <queue>using namespace std;struct node1 { int a, b; node1() {} node1(int _a, int _b): a(_a), b(_b) {} bool operator < (const node1 & x) const { return a > x.a; }};struct node2 { int a, b; node2() {} node2(int _a, int _b): a(_a), b(_b) {} bool operator < (const node2 & x) const { return b < x.b; }};int n, m, p;int main() { while (scanf("%d%d%d", &n, &m, &p) == 3) { priority_queue<node1> q1; priority_queue<node2> q2; int a, b; for (int i=0; i<n; i++) { scanf("%d%d", &a, &b); q1.push(node1(a, b)); } while (m--) { while (!q1.empty() && q1.top().a <= p) { q2.push(node2(q1.top().a, q1.top().b)); q1.pop(); } if (q2.empty()) break; p += q2.top().b; q2.pop(); } printf("%d\n", p); } return 0;}
- ZOJ 3230 Solving the Problems
- ZOJ 3230 Solving the Problems
- zoj 3230Solving the Problems//优先队列
- ZOJ 3230 Solving the Problems(优先队列)
- zoj 3230 Solving the Problems (优先队列)
- ZOJ 3230 Solving the Problems(数学 优先队列啊)
- Solving the Problems
- Solving the Problems Zju3230 解题报告
- Mastering the Information Age - Solving Problems with Visual Analytics
- Solving problems with proc
- The Problems of zoj By watashi
- window caffe compiler problems solving
- Tips for solving CSS problems in IE7
- Haskell : Functionally Solving Problems 部分学习笔记
- Problems Solving--Q&&A(Period One)
- Problems Solving--Q&&A(Period 2)
- ZOJ Problems 分类表
- Real-Life MDA: Solving Business Problems with Model Driven Architecture
- 关于cluster table(簇表)BSEG
- 71道经典Android面试题
- Effective C++ 学记之11 在operator=中处理“自我赋值“
- 【WPF】binding的使用
- Oracle DBA--查看表空间的使用情况SQL语句
- ZOJ 3230 Solving the Problems
- 应用之星:在线手机应用开发平台 不用搭建环境
- 设计模式之模板方法
- 免费试用Windows Azure云平台(无须提供信用卡)
- Delphi多线程下的ADO编程
- Android activity生命周期测试
- Fedora9安装samba服务
- linux raw socket
- crank工程的qnx系统移植