POJ 3614
来源:互联网 发布:box2d python 编辑:程序博客网 时间:2024/06/03 18:17
题目大意:
共有C头牛,为了使其更好的工作,需要给它涂上防晒霜。牛所能承受的阳光强度各不相同,处于一个区间。而防晒霜是能固定一个温度,如果这个温度处于牛的承受区间内,则适合此牛使用,否则不适合。
其中,防晒霜共有L中,每种有 i 瓶。
我的理解:
此处我借鉴了此人 的思想;
贪心+优先队列;
我的代码:
#include <iostream>#include <cstdio>#include <queue>#include <vector>#include <algorithm>#define MAX_N 2505using namespace std;typedef pair<int,int> P;priority_queue<int, vector<int>, greater<int> > que; int C,L;P cow[MAX_N],bot[MAX_N];int main(){freopen("D:/OJ/挑战程序设计竞赛/POJ3614.txt","r",stdin);const int INF = 1000000000;int j = 0;int result = 0;cin>>C>>L;for(int i = 0;i<C;i++){cin>>cow[i].first>>cow[i].second;}for(int i = 0;i<L;i++){cin>>bot[i].first>>bot[i].second;}sort(cow,cow+C);sort(bot,bot+L);for(int i = 0;i<L;i++){while(j<C && cow[j].first <= bot[i].first){que.push(cow[j].second);j++;}while(!que.empty() && bot[i].second){int x = que.top();que.pop();if(x< bot[i].first)continue;result++;bot[i].second--;} }cout<<result<<endl;return 0;}
阅读全文
0 0
- poj 3614
- poj 3614
- poj-3614
- poj 3614
- poj 3614
- poj 3614
- POJ 3614
- 【POJ】3614
- poj 3614 Sunscreen
- poj 3614 Sunscreen 贪心
- poj 3614 Sunscreen (贪心)
- POJ-3614-Sunscreen
- POJ 3614 Sunscreen
- poj-3614-Sunscreen
- POJ 3614 Sunscree
- poj 3614 Sunscreen 贪心
- POJ-3614 sunscreen
- poj 3614 贪心
- HDU1716 排列2【全排列+输出格式】
- iOS逆向之砸壳app
- POJ1738
- Oracle用命令行 导出、导入一个用户所有表数据和表结构(存储过程啊,视图啊等等)
- SpringMVC学习记录(六)--Validator验证
- POJ 3614
- 栅格系统
- Linux系统服务器上安装PHP
- Anykey在海事应用方案
- |1238|求数列的和
- POJ1426BFS
- 动态树
- java实现定时任务的三种方法
- 解决ScrollView嵌套ListView进入界面不在顶部的问题