运油问题
Oil Transport
题目详情
一艘油轮要把 3000 加仑油从港口 X 运到港口 Y,两港相距 1000 英里。
船每行驶 1 英里都会固定漏掉 1 加仑油(与载油量无关),且任何时刻最多只能装 1000 加仑。
船可以在途中任意位置建立储油点:把油卸下存放,之后再来取。
问:在最优方案下,最多能从 X 运到 Y 多少加仑油?(四舍五入到最接近的整数加仑。)
英文原题
An oil tanker ship is transporting gallons of oil from Port to Port which are miles apart. However, the ship loses gallon of oil for every mile it travels from spillage (at a constant rate) and can carry a max of gallons at any time. The ship can also dump any oil that it is carrying at any number of storage ports on the way from Port to Port and pick it up later. Assuming an optimal travel plan where you decide where to place any number of storage ports and how to carry the oil, how many gallons can you transport from Port to Port (round to the nearest gallon)?
解析
这是经典“分段搬运 / 沙漠运香蕉”问题。
当剩余油量需要分成 趟运输(每趟最多 1000)时,为把油向前推进 1 英里,需要有 次穿越该 1 英里(来回搬运),因此每推进 1 英里净消耗 加仑。
- 初始 3000 加仑,需要 趟,净消耗率 5 加仑/英里。推进 英里直到剩余 2000:
- 剩余 2000 加仑,需要 趟,净消耗率 3 加仑/英里。推进 英里直到剩余 1000:
此时已前进 英里。
- 剩余 1000 加仑只需 1 趟,消耗率 1 加仑/英里。剩余路程为
到达 Y 时剩余油为
四舍五入得到 加仑。
英文解析
This is the classic "staging/desert bananas" problem.
When the remaining amount of oil needs to be divided into transports (up to 1000 per transport), in order to advance the oil by 1 mile, it is necessary to cross the 1 mile (back and forth) times, so the net consumption per 1 mile is gallons.
- Initial 3000 gallons, requiring trips, net consumption rate 5 gallons/mile. Advance miles until 2000:
- 2,000 gallons remaining, requiring trips and a net consumption rate of 3 gallons/mile. Advance miles until 1000 is left:
You have now traveled miles.
- The remaining 1000 gallons only need 1 trip, the consumption rate is 1 gallon/mile. Remaining distance is
When reaching Y, the remaining oil is
Round to gallons.