poj 3045 Cow Acrobats
来源:互联网 发布:海马玩模拟器 for mac 编辑:程序博客网 时间:2024/05/08 09:20
/*贪心 风险值 = w - (wnow + snow) * 使得(wnow+snow)最大即可 */#include <cstdio>#include <cstring>#include <algorithm>using namespace std;#define MAX_N 100010const int inf = 1 << 29;const int maxn = 5e4+100;struct cow{ int w; int s; bool operator < (const cow &a) const{ return w+s < a.w + a.s; }}a[maxn];int n;long long sum;int main(){ while(scanf("%d", &n) != EOF){ sum = 0; for(int i = 0;i < n ;i++){ scanf("%d%d", &a[i].w, &a[i].s); sum += a[i].w; } sort(a, a + n); long long ans = -inf; for(int i = n-1;i >= 0; i--){ sum -= a[i].w; ans = max(ans, sum - a[i].s); } printf("%lld\n", ans); } return 0;}
0 0
- 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
- Cow Acrobats - 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 3109 Inner Vertices 树状数组+离散化
- C 语言的可变参数表函数的设计
- poj 3061 尺取法
- abstract类举例
- 小说爬虫
- poj 3045 Cow Acrobats
- FMDB
- Map三种遍历方式
- poj 2976 Dropping tests
- 【c++程序】求最大公约数
- poj 2886 Who Gets the Most Candies?
- 常用字符串长度计算函数
- Hdu 3341 Lost's revenge (ac自动机+dp+hash)
- poj 2566Bound Found