思路:

放一个链接

是我太懒了

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的更多相关文章

  1. POJ 3622 Gourmet Grazers(贪心)

    [题目链接] http://poj.org/problem?id=3622 [题目大意] 给出一些物品拥有两个属性值,价格和精美程度 给出一些需求表示要求获得的物品两个属性值的两种属性下界, 一个物品 ...

  2. POJ 2431 Expedition (priority_queue或者multiset可解)

    Expedition Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 18655   Accepted: 5405 Descr ...

  3. POJ 3253 Fence Repair C++ STL multiset 可解 (同51nod 1117 聪明的木匠)

    Fence Repair Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 53106   Accepted: 17508 De ...

  4. POJ 3038 贪心(multiset)

    题意: 思路: 1. 贪心 我们考虑肯定是走最近的最合适 想象自己是一个黑一日游的司机: 1.如果有乘客要上车,那么就让他上,收钱! 2.如果超载了,把距目的地最远的几个乘客踢下去,退钱. 3.行驶到 ...

  5. TTTTTTTTTTTTTTTTTTTTT POJ 3690 0与* 二维哈希 模板 +multiset

    Constellations Time Limit: 3000MS   Memory Limit: 65536K Total Submissions: 5923   Accepted: 1164 De ...

  6. 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 ...

  7. poj 2777 Count Color

    题目连接 http://poj.org/problem?id=2777 Count Color Description Chosen Problem Solving and Program desig ...

  8. poj 3625 Building Roads

    题目连接 http://poj.org/problem?id=3625 Building Roads Description Farmer John had just acquired several ...

  9. poj 2560 Freckles

    题目连接 http://poj.org/problem?id=2560 Freckles Description In an episode of the Dick Van Dyke show, li ...

随机推荐

  1. Linux 重启防火墙失败

    CentOS 7 执行service iptables start出现redirecting to systemctl ...Failed to ...not loaded. 如果出现以下错误,好像说 ...

  2. redhat 7 cenos 7 网络配置文件

    Cenos 7 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no DEFROUTE=yes IPV4_FAILURE_FATAL=no NAME=eth0 ...

  3. C语言编译和链接

    编译链接是使用高级语言编程所必须的操作,一个源程序只有经过编译.链接操作以后才可以变成计算机可以理解并执行的二进制可执行文件. 编译是指根据用户写的源程序代码,经过词法和语法分析,将高级语言编写的代码 ...

  4. web集群中经常使用的session同步解决方式及对照

    随着站点的功能越来越多,用户量越来越庞大,单节点模式已经严重不能支撑整个系统的正常运作,轻则用户页面訪问时间越来越慢.重则就会导致整个系统瘫痪.这时候 就须要优化或调整眼下的架构,大部分人就会採用各种 ...

  5. 开源 java CMS - FreeCMS2.3会员个人资料

    原文地址:http://javaz.cn/site/javaz/site_study/info/2015/28577.html​ 项目地址:http://www.freeteam.cn/ 个人资料 从 ...

  6. Python库之pyudev (一)

    库pyudev是libudev的python封装,libudev提拱了对本地设备的列举与查询API. 1.安装 pip install pyudev 2. 使用 2.1 开始 导入pyudev,验证库 ...

  7. iOS 9 适配,我咋还没遇到这么多坑呢呀

    iOS 9 适配,我咋还没遇到这么多坑呢呀 太阳火神的漂亮人生 (http://blog.csdn.net/opengl_es) 本文遵循"署名-非商业用途-保持一致"创作公用协议 ...

  8. 查看spark是否有僵尸进程,有的话,先杀掉。可以使用下面命令

    查看spark是否有僵尸进程,有的话,先杀掉.可以使用下面命令yarn application -listyarn application -kill <jobid>

  9. 范型在java中的应用

    根据泛型在java中的不同位置,大致可以分为类泛型.方法泛型和接口泛型.以下三个Demo基本展现三种泛型的用法,其中接口泛型又分两种情况描述.类泛型和方法泛型 import java.util.Arr ...

  10. rails 开发随手记 7

    jQuery 1.9 中如何修改选择项 $("select option:contains(teacher5)").prop('selected', 'selected'); 效果 ...