USACO 1.4 Ski Course Design 翻译&解题报告

农夫约翰为了避免新税法对滑雪训练营的限制,需要调整山丘高度,使得最高和最低山丘高度差不超过17。成本按变化量的平方计算。问题是找出最小成本。解决方案包括通过遍历所有可能的高程间隔,计算每座山丘的调整成本,总成本为O(NM),N是山丘数量,M是高度范围。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Farmer John has N hills on his farm (1 <= N <= 1,000), each with an integer elevation in the range 0 .. 100. In the winter, since there is abundant snow on these hills, FJ routinely operates a ski training camp.

Unfortunately, FJ has just found out about a new tax that will be assessed next year on farms used as ski training camps. Upon careful reading of the law, however, he discovers that the official definition of a ski camp requires the difference between the highest and lowest hill on his property to be strictly larger than 17. Therefore, if he shortens his tallest hills and adds mass to increase the height of his shorter hills, FJ can avoid paying the tax as long as the new difference between the highest and lowest hill is at most 17.

If it costs x^2 units of money to change the height of a hill by x units, what is the minimum amount of money FJ will need to pay? FJ can change the height of a hill only once, so the total cost for each hill is the square of the difference between its original and final height. FJ is only willing to change the height of each hill by an integer amount.

农夫约翰在他的农场有N座山(1 <= N <= 1,000),每个都有0到100的整数高度。在冬天,由于这些山上积雪很多,FJ经常进行滑雪训练营。

不幸的是,FJ刚刚发现了一项新的税收,明年将对用作滑雪训练营的农场进行评估。然而,仔细阅读法律后,他发现滑雪营的官方定义要求他的财产上的最高和最低山丘之间的差异严格大于17.因此,如果他缩短他的最高山丘并增加质量为了增加他的矮山的高度,只要最高和最低山丘之间的新差异最多为17,FJ就可以避免缴纳税款。

如果以x单位改变山丘高度需要花费x ^ 2个单位的金额,那么FJ需要支付的最低金额是多少?

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值