poj 3045 Cow Acrobats (贪心!!不是二分,)
Input
Output
Sample Input
3 10 3 2 5 3 3
Sample Output
2
Hint
样例解释: 把重量为10的牛放在底部。她将携带另外两只牛,所以她的崩溃的风险是2 +3-3= 2。其他的奶牛有比她低的崩溃风险。
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
#define MAX 50000
struct Cow
{int weight, strength;bool operator<(const Cow& other)const{//return other.weight<weight;return other.strength+other.weight<strength+weight;}
}cow[MAX];
int main()
{int N;while(cin>>N){int total = 0;for (int i=0;i<N;++i){scanf("%d%d",&cow[i].weight,&cow[i].strength);total+= cow[i].weight;}sort(cow,cow+N);int risk = 0x80808080;for(int i=0; i<N;++i){total-=cow[i].weight; // 减去自己的重量risk=max(risk,total-cow[i].strength); // 计算risk}cout <<risk<<endl;}return 0;
}
poj 3045 Cow Acrobats (贪心!!不是二分,)相关推荐
- POJ 3045 Cow Acrobats (最大化最小值)
题目链接:click here~~ [题目大意] 给你n头牛叠罗汉.每头都有自己的重量w和力量s,承受的风险数rank就是该牛上面全部牛的总重量减去该牛自身的力量,题目要求设计一个方案使得全部牛里面风 ...
- POJ3045 Cow Acrobats —— 思维证明
题目链接:http://poj.org/problem?id=3045 Cow Acrobats Time Limit: 1000MS Memory Limit: 65536K Total Sub ...
- POJ 3660 Cow Contest [Floyd]
POJ - 3660 Cow Contest http://poj.org/problem?id=3660 N (1 ≤ N ≤ 100) cows, conveniently numbered 1. ...
- poj 1985 Cow Marathon 【树的直径】
求树的直径 /* POJ:1985 Cow Marathon 2014/10/12/21:18 Yougth*/ #include <cstdio> #include <iostre ...
- POJ 3111 K Best 贪心 二分
题目链接: http://poj.org/problem?id=3111 题目描述: 在N个物品中让你选出K个, 使得平均价值最大 解题思路: 这是我错的代码......一会儿回来改啊......一会 ...
- POJ 3618 Best Cow Line(贪心算法)
Best Cow Line Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 30454 Accepted: 8126 De ...
- POJ 3617 Best Cow Line 贪心算法
Best Cow Line Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 26670 Accepted: 7226 Descri ...
- POJ 3617 Best Cow Line 贪心
不能单纯比较头尾两个字符,应该比较头尾两个字符串. //#pragma comment(linker, "/STACK:1024000000,1024000000") #inclu ...
- 【POJ 3614 Sunscreen】贪心 优先级队列
题目链接:http://poj.org/problem?id=3614 题意:C头牛去晒太阳,每头牛有自己所限定的spf安全范围[min, max]:有L瓶防晒液,每瓶有自己的spf值和容量(能供几头 ...
最新文章
- html 11 内联(行内)
- [TT]-Trustonic acronyms
- 设置Ext tab的宽度自动适应
- 连载《一个程序猿的生命周期》-2.城市校园生活
- TypeScript基本数据类型
- 预充电电路工作原理_变频冰箱开关电源电路工作原理及检修。
- 单纯型法Ⅱ(bzoj 1061: [Noi2008]志愿者招募)
- linux虚拟机网卡无法启动
- sql 查找重复数据,并且重复数据有子集
- CSS3实现的几个小loading效果
- JavaScript-Date类的getMonth方法释疑
- vlfeat各种版本下载链接:
- Web渗透测试实战——(1)Web渗透测试简介
- 用excel绘制统计图
- 计算机三级 信息安全技术题库——选择题1
- 渥太华计算机读研的好学校,加拿大硕士留学:渥太华最好的大学硕士项目
- mysql skewed_Hive分区字段含中文报错问题解决方案
- js二维码样式生成插件easy.qrcode.js
- Qt解决资源文件中添加图片,对应控件不显示图片的问题
- tensorflow之constant()函数