HDU 4296 Buildings
来源:互联网 发布:php阿里蜘蛛池 编辑:程序博客网 时间:2024/05/22 12:00
PDV = s - w[i] - s[i] = s - (w[i] + s[i]) 每次选出里面的w + s 最大的即可,排序+贪心。
#include"iostream"#include"algorithm"using namespace std;struct node{ int w,s;};node a[100005];int cmp(node a,node b){ return a.w+a.s<b.w+b.s;}int main(){ int n; while(cin>>n) { for(int i=0;i<n;i++) cin>>a[i].w>>a[i].s; sort(a,a+n,cmp); long long maxx=-1e9,sum=0; for(int i=0;i<n;i++) { if(sum-a[i].s>maxx) maxx=sum-a[i].s; sum+=a[i].w; } if(maxx<0) cout<<0<<endl; else cout<<maxx<<endl; } return 0;}
0 0
- [hdu] 4296 Buildings
- HDU 4296 Buildings
- HDU 4296 Buildings
- hdu 4296 Buildings
- hdu - 4296 - Buildings
- HDU 4296 buildings
- hdu 4296(buildings)
- hdu-4296-Buildings
- HDU 4296 Buildings(贪心)
- HDU-4296-Buildings
- hdu 4296 Buildings(贪心)
- HDU 4296 Buildings
- 贪心-- HDU - 4296 Buildings
- hdu 4296 Buildings
- hdu 4296 Buildings
- HDU 4296 Buildings 贪心
- HDU 4296 Buildings
- Buildings HDU 4296
- JStorm介绍
- 阿里15年前端实习笔试-做的答案
- hibernate实验
- C语言顺序表的简单实现
- poj---1751 Highways
- HDU 4296 Buildings
- 进程通信---管道通信
- android群英传笔记--第三章--自定义控件三简单形状View
- effective C++之静态全局变量的初始化问题及解决办法
- 一个简单的自定义DialogFragment
- 应用程序初次运行数据库配置小程序(Java版)
- 继承小结
- 弱引用的集合类
- Storm介绍