*Protecting the Flowers(POJ 3262, 贪心)
来源:互联网 发布:windows桌面图标分类 编辑:程序博客网 时间:2024/05/17 22:04
题目链接
题目大意:牛在花园里吃花,牛i每分钟吃花Di,牵走牛i再回来的时间为2Ti,求最小损失花数。
#include<cstdio>#include<algorithm>using namespace std;const int MAX_N = 100005;struct cow {int T, D;} a[MAX_N];int N, rest_D;long long ans;bool cmp(cow b, cow c){return b.T*c.D < c.T*b.D;}void init(){rest_D = 0;for(int i=0; i<N; i++){scanf("%d%d", &a[i].T, &a[i].D);rest_D += a[i].D;}ans = 0;}void f(){for(int i=0; i<N; i++){rest_D -= a[i].D;ans += 2 * a[i].T * rest_D;}}int main(){while(~scanf("%d", &N)){init();sort(a, a+N, cmp);f();printf("%lld", ans);}return 0;}
阅读全文
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(贪心)
- 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 (贪心 + 优化)
- Apache Mina 入门 (二)—— 异步通信机制
- CPSR_C
- JAVA线程
- 17个新手常见Python运行时错误
- js节流
- *Protecting the Flowers(POJ 3262, 贪心)
- Myeclipse 2017破解版教程
- Java开发练习9.1 网络编程UDP
- POJ 刷题系列:1068. Parencodings
- 数据结构单链表之创建链表(头插法)
- 数据结构实验之查找七:线性之哈希表
- git_初探_连接远程访问库
- 基于Qt5.9的QMQTT协议跟EMQ代理服务器的连接教程
- springBoot配置路径