【POJ】3045
来源:互联网 发布:淘宝发错货赔偿规则 编辑:程序博客网 时间:2024/06/05 21:47
http://poj.org/problem?id=3045
N头牛叠罗汉,每头牛的力气是S_i,体重是W_i,倒下的风险D是身上的牛的体重和减去S_i,求D的最大值。
力气越大、体重越重的牛放越下面。
然后一个一个算就好了。
#include <iostream>#include <cstdio>#include <cstring>#include <cmath>#include <queue>#include <algorithm>using namespace std;int n;struct cow{ int w; int s;}c[500005];int sum=0;int ans=-99999999;bool cmp(cow a,cow b){ return a.s+a.w>b.s+b.w;}int main(){ cin >> n; for (int i=0;i<n;i++){ cin >> c[i].w >> c[i].s; sum+=c[i].w; } sort(c,c+n,cmp); for (int i=0;i<n;i++){ sum-=c[i].w; ans=max(ans,sum-c[i].s); } cout << ans << endl;}
阅读全文
0 0
- POJ-3045
- 【POJ】3045
- poj-3045 Cow Acrobats
- POJ 3045 Cow Acrobats
- POJ 3045-Cow Acrobats
- POJ-3045-Cow Acrobats
- POJ 3045 Cow Acrobats
- poj 3045 Cow Acrobats
- POJ 3045 Cow Acrobats
- poj 3045 Cow Acrobats
- POJ-3045Cow Acrobats
- poj 3045 Cow Acrobats
- POJ
- poj
- POJ
- POJ
- poj
- poj
- requests库入门-4-HTTP请求方法和用requests举例不带参数的请求
- 平衡树学习记录
- Nmap 渗透实列
- window窗口对象
- Myeclipse错误:Errors occurred during the build. Errors running builder 'DeploymentBuilder' on project
- 【POJ】3045
- OSX上pf的简单配置笔记
- STM8学习笔记三----按键实验
- React 组件解耦之道
- QT 多线程(QThread)里调用线程池(QThreadPool )与主界面进行通讯
- JavaScript中SetInterval与setTimeout的用法详解
- bzoj1500维修数列splay
- java设计模式之--工厂模式
- UnityShader顶点动画实现Mage-Fiers漂移效果