poj 3614
来源:互联网 发布:淘宝菜鸟电子面单申请 编辑:程序博客网 时间:2024/06/03 17:07
贪心外加优先队列
#include<stdio.h>#include<queue>#include<string.h>#include<algorithm>//#include <utility>using namespace std;priority_queue <int ,vector<int>,greater<int> > q;pair <int,int> a[2505];pair <int,int> b[2505];int main(){ int c,l; int i,j,k,ans; while(scanf("%d%d",&c,&l)!=EOF){ for(i=0;i<c;i++) { scanf("%d%d",&a[i].first,&a[i].second); } for(j=0;j<l;j++) { scanf("%d%d",&b[j].first,&b[j].second); } sort(a,a+c); sort(b,b+l); ans=0; j=0; for(i=0;i<l;i++){ while(j<c&&a[j].first<=b[i].first) q.push(a[j].second),j++; while(q.size()&&b[i].second!=0){ k=q.top(); q.pop(); if(k>=b[i].first){ ans++; b[i].second--; } } } printf("%d\n",ans); } 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 贪心
- 内容提供者—Content Provider(一)
- SQLiteOpenHelper数据库操作
- 字符串——日积月累
- FreeBSD---ssh
- 加速和改进PCB布线
- poj 3614
- Algorithm学习笔记 --- 铁轨(火车重排问题)
- Android 代码混淆策略
- GDAL书籍
- JAVA核心技术 第四章 对象与类 类设计技巧
- PHP实现多线程 异步 非阻塞
- 【IOS 细节笔记】遇到的疑问记载
- 设计模式-原型模式
- 数据结构《15》----二叉树的层序遍历