POJ 2431 Expedition
来源:互联网 发布:电脑怎么用手机淘宝 编辑:程序博客网 时间:2024/06/04 18:46
#include<stdio.h>#include<string.h>#include<queue>#include<algorithm>using namespace std;const int maxn = 3e4+5;struct node{int dis;int fue;bool operator< (const node&I)const { //按照fue由da到xiao排列 return I.fue > fue; }};bool com (node a, node b){return a.dis > b.dis;}node a[maxn];priority_queue <node> pque;int main (){int n, l, p, tempdis,i,ans;scanf("%d",&n);memset(a,0,sizeof(a));for (int i = 0; i < n; i++){scanf("%d%d",&a[i].dis, &a[i].fue );}sort(a,a+n,com);scanf("%d%d", &l, &p);tempdis = p;i = 0;ans = 0;while (!pque.empty() )pque.pop() ;while ( tempdis < l){while ( i < n && a[i].dis >= l - tempdis){ // 符号写反,wa了1晚上... pque.push(a[i]);i++; }if (!pque.empty() ){tempdis += (pque.top()).fue ;pque.pop() ;ans++;}else break;}if (tempdis >= l){printf("%d\n",ans);}else printf("-1\n");}
阅读全文
0 0
- poj 2431 Expedition 贪心
- poj 2431 Expedition
- poj 2431 Expedition
- POJ-2431-Expedition
- poj 2431 Expedition
- POJ 2431 Expedition
- POJ 2431 Expedition(树)
- POJ 2431 Expedition
- poj 2431 Expedition
- POJ 2431 Expedition
- POJ(2431)Expedition
- poj 2431 Expedition
- poj 2431 Expedition
- [POJ 2431]Expedition
- poj 2431 Expedition
- POJ 2431 Expedition
- poj 2431 Expedition
- POJ Expedition 2431
- CSDN 人工智能发展动态在线学习笔记
- Java———反射机制
- Android动画学习(一)之动画概述和帧动画实现
- 带权并查集:CF-2015 ACM Arabella Collegiate Programming Contest(F题)
- Android Media(多媒体)播放Module raw下的音乐
- POJ 2431 Expedition
- C++ Socket编程步骤
- 新手上路 js 之 this关键字 代码笔记
- Linux系统安装MySQL
- springmvc上传文件的三种方式
- 搭建ssm项目环境
- 自省
- 13.3小米笔记本安装ubuntu(linux)后无法正常打开wifi的解决方法
- Tensorflow:深度神经网络DNN预测波士顿房价(boston house price)【一】