Codeforces 1458 B Glass Half Spilled

这篇博客详细介绍了Codeforces 1458 B题——Glass Half Spilled,讨论如何在倒水过程中最大化收集的水量。文章提供了解题思路、动态规划的解决方案以及复杂度分析,适合ACM竞赛爱好者阅读。
摘要由CSDN通过智能技术生成

更好的阅读体验

B. Glass Half Spilled

开启传送门

题目描述

There are n n n glasses on the table numbered 1 , … , n 1, \ldots, n 1,,n. The glass i i i can hold up to a i a_i ai units of water, and currently contains b i b_i bi units of water.

You would like to choose k k k glasses and collect as much water in them as possible. To that effect you can pour water from one glass to another as many times as you like. However, because of the glasses’ awkward shape (and totally unrelated to your natural clumsiness), each time you try to transfer any amount of water, half of the amount is spilled on the floor.

Formally, suppose a glass i i i currently contains c i c_i ci units of water, and a glass j j j contains c j c_j cj units of water. Suppose you try to transfer x x x units from glass i i i to glass j j j (naturally, x x x can not exceed c i c_i ci). Then, x / 2 x / 2 x/2 units is spilled on the floor. After the transfer is done, the glass i i i will contain c i − x c_i - x cix units, and the glass j j j will contain min ⁡ ( a j , c j + x / 2 ) \min(a_j, c_j + x / 2) min(aj,cj+x/2) units (excess water that doesn’t fit in the glass is also spilled).

Each time you transfer water, you can arbitrarlly choose from which glass i i i to which glass j j j to pour, and also the amount x x

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

zuhiul

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值