poj 3262 Protecting the Flowers 【贪心】
来源:互联网 发布:淘宝刀创 编辑:程序博客网 时间:2024/05/16 17:55
这道题跟hdoj4882 ZCC Loves Codefires 几乎一模一样,只是改了一下下。
解题策略 :参考hdoj4882的解法 http://blog.csdn.net/shengweisong/article/details/38316699
题目链接 http://poj.org/problem?id=3262
代码:
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;typedef struct{double t, d;double r;}str;str s[100005]; int cmp(str a, str b){return a.r<b.r;}int main(){int n, i, j;while(scanf("%d", &n) == 1){for(i = 0; i < n; i ++){scanf("%lf%lf", &s[i].t, &s[i].d);s[i].r = s[i].t/s[i].d;}sort(s, s+n, cmp);__int64 sum =0, time = 2*s[0].t; //和hdoj4882 这处有点小小的改变for(i = 1; i < n; i ++){sum += time *s[i].d;time += 2*s[i].t;}printf("%I64d\n", sum);}}
0 0
- POJ 3262 Protecting the Flowers 贪心
- poj 3262 Protecting the Flowers (贪心)
- poj 3262 Protecting the Flowers(贪心)
- poj 3262 Protecting the Flowers 【贪心】
- poj 3262 Protecting the Flowers(贪心)
- Protecting the Flowers - POJ 3262 贪心
- poj 3262 Protecting the Flowers(贪心)
- POJ 3262 Protecting the Flowers【贪心】
- POJ 3262 - Protecting the Flowers(贪心)
- POJ 3262 Protecting the Flowers (贪心)
- POJ 3262 Protecting the Flowers(贪心)
- POJ 3262 Protecting the Flowers(贪心)
- Poj 3262 Protecting the Flowers【贪心】
- POJ 3262 Protecting the Flowers 贪心
- 【贪心】POJ 3262 Protecting the Flowers
- *Protecting the Flowers(POJ 3262, 贪心)
- POJ 3262 Protecting the Flowers(贪心,需要小小优化一下)
- POJ 3262-Protecting the Flowers(贪心+前缀和)
- [LeetCode] Sort Colors
- POSIX 线程详解
- Centos6.5上安装xen及图形化界面管理
- UVa1647Computer Transformation
- IOS-DEMO6 LayerMask
- poj 3262 Protecting the Flowers 【贪心】
- hdu 4634 Swipe Bo
- XBOOT核心组件之KOBJ技术详解
- 线段树扫描线uva11983
- 3.6.9 Using AUTO_INCREMENT
- Poj2318
- [LeetCode] Plus One
- 【数据结构_map容器迭代】Anagrams
- mahou 安装实例