题目大意是要n个人要过桥,过桥需要手电筒,可以两个人一起过,算慢的那个人的速度,如果还有人要过则需要一个人拿着手电筒回来,问全部人过完桥需要多长时间并给出过桥方案。
很经典的贪心问题(据说还是Microsoft的面试题?),先按速度进行排序。首先考虑人数多于3的情况,很明显只有两种选择最快的带最慢和次慢的组合或者最快和次快+最慢和次慢的组合,比较两者耗时来进行选择,一直处理到只剩下不多于3个人为止。此时的选择已经是唯一的了,对应不同的n处理即可。
3012992 2008-07-29 21:02:02 Accepted 1877 FPC 00:00.01 412K IwfWcf
hermes birkin, http://www.hermesbirkin.org/
回复删除chanel outlet, http://www.chaneloutletstore.us.com/
nike free uk, http://www.nikefreerunning.org.uk/
ray ban sunglasses, http://www.raybansunglass.com.au/
rolex watches, http://www.rolexwatches.in.net/
ray ban sunglasses, http://www.ray-bansunglasses.eu.com/
yoga pants, http://www.yogapants.us.com/
beats headphones, http://www.beats-headphones.in.net/
michael kors outlet, http://www.michaelkorsusa.us/
pandora jewelry, http://www.pandora.eu.com/
cheap ugg boots, http://www.cheapuggboots.net.co/
air jordan shoes, http://www.airjordanshoes.us.org/
louis vuitton outlet, http://www.louisvuittonus.us.com/
ed hardy clothing, http://www.edhardy.us.com/
replica handbags, http://www.replicahandbag.us.com/
the north face outlet store, http://www.thenorthfaceoutletstores.org/
tiffany jewellery, http://www.tiffanyjewelleryoutlets.co.uk/
lebron james shoes, http://www.lebronjamesshoes.in.net/
gucci handbags, http://www.guccihandbags-outlet.co.uk/
true religion outlet, http://www.truereligionoutletstore.us.com/
swarovski jewelry, http://www.swarovski.in.net/
michael kors outlet, http://michaelkors.outletonlinestores.us.com/
swarovski outlet, http://www.swarovski-outlet.co.uk/
wedding dresses, http://www.weddingdressesoutlet.co.uk/
louis vuitton handbags, http://www.louisvuittonhandbagsoutlet.co.uk/
lebron james shoes, http://www.lebronjames.us.com/
nike trainers, http://www.niketrainers.me.uk/
kobe shoes, http://www.kobeshoes.us/
cheap snapbacks, http://www.cheapsnapbacks.us.com/
1003maoqiuyun
ray ban sunglasses discount
回复删除canada goose
nike outlet online
canada goose jackets
coach outlet
tiffany outlet
birkenstock outlet
pandora outlet
kate spade
canada goose outlet
mt20180702
20180829 xiaoou
回复删除toms outlet
ugg boots clearance
michael kors handbags
true religion outlet
ralph lauren outlet
ralph lauren outlet
jordan 4
mishka snapbacks
james harden shoes
michael kors outlet online
canada goose
回复删除lebron 17 shoes
lebron shoes
jordan shoes
bape hoodie
curry 5 shoes
air max 270
jordan sneakers
balenciaga shoes
yeezy boost 350
f6x61n6a03 i1b44b0j13 g8g54b4e76 b8b33x6z89 b9m85e3t79 l5h39g8t26
回复删除