POJ 3622 multiset
思路:
放一个链接
是我太懒了
http://blog.csdn.net/mars_ch/article/details/52835978
嗯她教的我(姑且算是吧)
(一通乱搞就出来了…)
//By SiriusRen
#include <set>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 100500
int n,m,id=1;
long long ans;
struct Node{int a,b;}cow[N],grass[N];
bool cmp(Node a,Node b){return a.b>b.b;}
multiset<int>s;
multiset<int>::iterator it;
int main(){
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
scanf("%d%d",&cow[i].a,&cow[i].b);
for(int i=1;i<=m;i++)
scanf("%d%d",&grass[i].a,&grass[i].b);
sort(cow+1,cow+1+n,cmp),sort(grass+1,grass+1+m,cmp);
for(int i=1;i<=n;i++){
while(grass[id].b>=cow[i].b)s.insert(grass[id].a),id++;
it=s.lower_bound(cow[i].a);
if(it==s.end()){puts("-1");return 0;}
ans+=*it;
s.erase(it);
}
printf("%lld\n",ans);
}
POJ 3622 multiset的更多相关文章
- POJ 3622 Gourmet Grazers(贪心)
[题目链接] http://poj.org/problem?id=3622 [题目大意] 给出一些物品拥有两个属性值,价格和精美程度 给出一些需求表示要求获得的物品两个属性值的两种属性下界, 一个物品 ...
- POJ 2431 Expedition (priority_queue或者multiset可解)
Expedition Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 18655 Accepted: 5405 Descr ...
- POJ 3253 Fence Repair C++ STL multiset 可解 (同51nod 1117 聪明的木匠)
Fence Repair Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 53106 Accepted: 17508 De ...
- POJ 3038 贪心(multiset)
题意: 思路: 1. 贪心 我们考虑肯定是走最近的最合适 想象自己是一个黑一日游的司机: 1.如果有乘客要上车,那么就让他上,收钱! 2.如果超载了,把距目的地最远的几个乘客踢下去,退钱. 3.行驶到 ...
- TTTTTTTTTTTTTTTTTTTTT POJ 3690 0与* 二维哈希 模板 +multiset
Constellations Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 5923 Accepted: 1164 De ...
- poj 1564 Sum It Up
题目连接 http://poj.org/problem?id=1564 Sum It Up Description Given a specified total t and a list of n ...
- poj 2777 Count Color
题目连接 http://poj.org/problem?id=2777 Count Color Description Chosen Problem Solving and Program desig ...
- poj 3625 Building Roads
题目连接 http://poj.org/problem?id=3625 Building Roads Description Farmer John had just acquired several ...
- poj 2560 Freckles
题目连接 http://poj.org/problem?id=2560 Freckles Description In an episode of the Dick Van Dyke show, li ...
随机推荐
- virt-install 创建虚拟机
[root@kvm-server vm]# qemu-img create -f qcow2 centos69b-disk0.qcow2 10G Formatting 'centos69b-disk0 ...
- 企业级URL检测脚本
#!/bin/bash #检查web url 是否正常 . /etc/init.d/functions #引用系统函数库 #判断传参个数是否为一个 function usage(){ echo $&q ...
- mysql中文乱码解决方式
近期项目使用到mysql.却突然出现了中文乱码问题.尝试了多种方案,最终解决乱码问题,总结一下解决方式,给遇到同样问题的人一点參考. 中文乱码的原因 1.安装mysqlserver的时候编码集设定有问 ...
- 可替代google的各种搜索引擎
http://www.aol.com http://www.duckduckgo.com http://www.gfsoso.com http://www.googlestable.com http ...
- 又见关系并查集 以POJ 1182 食物链为例
简单的关系并查集一般非常easy依据给出的关系搞出一个有向的环,那么两者之间的关系就变成了两者之间的距离. 对于此题: 若u.v不在一个集合内,则显然此条语句会合法(暂且忽略后两条.下同). 那么将f ...
- Oracle单实例情况下的library cache pin的问题模拟与问题分析
Oracle单实例情况下的library cache pin的问题模拟与问题分析 參考自: WAITEVENT: "library cache pin" Reference Not ...
- Find and counter
Find: In a sense, find is the opposite of the [] operator. Instead of taking an index and extracting ...
- Laravel-自定全局函数
Laravel-自定全局函数 标签(空格分隔): php 习惯了 使用 ThinkPHP 框架,有一个公共方法类在代码编写上会快捷很多,所以有必要在此进行配置一番. 实现 在 app 创建文件夹 He ...
- 解析UML用例图中include与extend的区别
UML用例图有很多值得学习的地方,这里向大家简单介绍一下UML用例图中include与extend的区别,希望本文的介绍对你有所帮助. 本文和大家重点讨论一下UML用例图中include与extend ...
- Android实现App版本自动更新
现在很多的App中都会有一个检查版本的功能.例如斗鱼TV App的设置界面下: 当我们点击检查更新的时候,就会向服务器发起版本检测的请求.一般的处理方式是:服务器返回的App版本与当前手机安装的版本号 ...