【POJ】3262
来源:互联网 发布:mac如何连接无线键盘 编辑:程序博客网 时间:2024/06/15 13:06
http://poj.org/problem?id=3262
奶牛每分钟吃掉D朵花,赶走它需要T分钟(来回加倍)。
求最小损失花朵数量。
优先赶走吃得多且走的慢的牛。
#include<iostream> #include<algorithm> using namespace std;int N;long long sum[100010];long long ans=0;struct cow{ long long t,d;}c[100010];int cmp(cow a,cow b){ return (a.t*1.0/a.d)<(b.t*1.0/b.d);}int main() { cin >> N; for(int i=0;i<N;++i){ cin >> c[i].t >> c[i].d; } sort(c,c+N,cmp); sum[N-1]=0; for(int i=N-2;i>=0;i--){ sum[i]=sum[i+1]+c[i+1].d; } for(int i=0;i<N;++i){ ans+=2*c[i].t*sum[i]; } cout << ans << endl;}
阅读全文
0 0
- poj 3262
- poj 3262
- 【POJ】3262
- POJ 3262
- poj 3262 贪心
- poj 3262贪心
- poj 3262 比例贪心
- POJ 3262 贪心
- poj 3262 贪心比率
- 贪心 POJ 3262
- POJ 3262 (贪心)
- poj 3262 贪心
- POJ
- poj
- POJ
- POJ
- poj
- poj
- [笔记分享] [SPI] SPI 协议小结
- yii自带rbac数据表分析
- js模拟双色球
- Python爬虫Cookie的使用
- 用css做一个跳动的心
- 【POJ】3262
- 开启我的 CSDN 博客之旅
- Struts2简介
- HDU 5634 Rikka with Phi
- c语言-大数乘法(16进制)
- 如何从零开始制作一款日式AVG游戏
- firewalld配置
- [笔记分享] [SPI] MSM8X60 SPI 小结
- 心形图片墙,鼠标移动到图片上并放大