poj 3262 Protecting the Flowers (贪心)
来源:互联网 发布:数据库中的模式 编辑:程序博客网 时间:2024/05/01 03:48
题意:
有n个牛在FJ的花园乱吃。
所以FJ要赶他们回牛棚。
每个牛在被赶走之前每秒吃Di个花朵。赶它回去FJ要花的时间是Ti。在被赶走的过程中牛就不能乱吃了
分析:
1、优先赶吃单位时间内吃花快的牛。
2、注意大数陷阱。
#include<cstdio>#include<algorithm>using namespace std;struct node{ int t,d;}cow[100010];bool cmp(node x,node y){ return x.d*y.t > x.t*y.d;}int main(){ int n; while(scanf("%d",&n)!=EOF) { for(int i=0;i<n;i++) scanf("%d%d",&cow[i].t,&cow[i].d); sort(cow,cow+n,cmp); long long ans=0; int tt=0; for(int i=0;i<n;i++) { ans+=cow[i].d*tt; tt+=cow[i].t*2; } printf("%lld\n",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(贪心)
- 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(贪心+前缀和)
- PHP运行出现Notice : Use of undefined constant 的解决办法
- android 设置默认launcher 附上代码
- OpenCv IplImage 转 cv::Mat
- 画线
- equals方法及对其进行重写
- poj 3262 Protecting the Flowers (贪心)
- 关于学java要掌握的知识问题
- Zigbee 设置信道,PANID,发射功率
- activity跳转时的生命周期
- 分享几个免费Cocos2d-x游戏源码
- IOS 多语言本地化 完美解决方案【自动+手动】
- 使用pt-stalk诊断MySQL问题
- VMware-vSphere-SDK-5.0 实现快照还原(一)获取最新快照名称
- ANT简明教程