Protecting the Flowers POJ - 3262

农夫约翰像往常一样去砍柴,留下N头(2≤N≤10万头)牛在吃草。当他回来时,他惊恐地发现那群牛正在他的花园里吃他美丽的花。为了将随后的损失降到最低,FJ决定立即采取行动,把每头牛运回自己的谷仓。

每头奶牛i所处的位置距离自己的牲口棚Ti分钟(1≤Ti≤2,000,000)。此外,在等待运输时,她每分钟破坏Di(1≤Di≤100)朵花。不管他怎么努力,FJ一次只能把一头牛运回她的谷仓。将奶牛i移到它的谷仓需要2×Ti分钟(Ti到那里,Ti返回)。FJ从花圃出发,把牛送到它的谷仓,然后走回花丛,不花额外的时间去找下一头需要运输的牛。

编写一个程序来确定FJ应该捡起奶牛的顺序,从而使被破坏的花朵总数最小化。

输入

第一行:一个整数N

行2 . .N+1:每一行包含两个空格分隔的整数,Ti和Di,它们描述了一头奶牛的特征

输出

第1行:一个整数,它是被破坏的花的最小数量

Sample Input

6
3 1
2 5
2 3
3 2
4 1
1 6

Sample Output

86

思路:贪心,应该送走破坏力较大的牛,假如只剩两头牛A,B,sumA是牛A的破坏力 

           sumB = eastB*timeA*2          sumA = eastA*timeB*2    两端同时除以timeA*timeB

           sumB = eastB/timeB*2          sumA = eastA*timeA*2 

所以题中 d/t 较大的牛破坏力大

#include<iostre
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
阅读下面材料,在空格处填入适当的内容(1个单词)或使用括号中单词的正确形式。 If including inter-state sections, those not protecting the northern border of China, the oldest _____56____(exist) section of the Great Wall of China was the Qi State "Great Wall". It stretches for over 500 kilometers (300 miles) from the Yellow River at Jinan eastwards to the East China Sea, almost ___57____(divide) Shandong Province in half. The "Great Wall" of the Qi State was ___58____(initial) built around 650 BC, and expended during the Warring States Period (475–221 BC). Before the Qi State Wall was built, natural barriers, i.e. rivers and mountain ranges, formed ____59_____ only defensible boundaries between territories as barriers ___60____ enemies. The State of Qi built its Great-Wall-esque military barrier along its southern border to prevent attacks from the State of Lu and the State of Chu. However, rapid development and ____61____(construct) have brought many new problems and challenges in protecting the wall. ____62____ is necessary to provide a solid legal guarantee for its conservation. To tackle the challenges, Shandong Province has passed a regulation protecting the structure____63____will take effect on Jan. 1. This year, Shandong has added 860 patrol posts in seven cities along the Qi wall, mainly recruiting farmers living nearby. Guo Jialian has been patrolling the section of the wall in Guangli village for three months. "I need to check ____64______ there is any damage to the wall that is caused by people digging earth from it. Awareness of protecting the Qi wall _____65_____ (enhance) in recent years. We all know the wall is a cultural relic," says Guo, adding that he frequently sees tourists coming to visit the ancient structure.
02-06

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值