Liebig's Barrels CodeForces - 985C (贪心)】的更多相关文章

链接 大意:给定$nk$块木板, 要制作$n$个$k$块板的桶, 要求任意两桶容积差不超过$l$, 每个桶的容积为最短木板长, 输出$n$个桶的最大容积和 假设最短板长$m$, 显然最后桶的体积都在$[m,m+l]$范围内, 就是说需保证每个桶都至少有一块板在$[m,m+l]$范围. 考虑贪心逐步调整, 假设$m+l$足够多的话, 可以先尽量连续得选最短的边做桶, 最后将$m+l$分给剩余桶即为最大容积. 如果不够多的话, 就要选出$m+l-1$分给剩余桶, 还不够就选择$m+l-2$, 直到所…
Liebig's Barrels time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have m = n·k wooden staves. The i-th stave has length ai. You have to assemble n barrels consisting of k staves each, y…
Liebig's Barrels time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have m = n·k wooden staves. The i-th stave has length ai. You have to assemble n barrels consisting of k staves each, y…
http://codeforces.com/contest/985/problem/C C. Liebig's Barrels time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have m = n·k wooden staves. The i-th stave has length ai. You have to as…
题目 题意: 有n * k块木板,每个木桶由k木板组成,每个木桶的容量定义为它最短的那块木板的长度. 任意两个木桶的容量v1,v2,满足|v1-v2| <= d. 问n个木桶容量的最大的和为多少,或者说明不可能做出这样的n个木桶. 思路: 一道纯粹的贪心题,可以确定最小的数MIN,那莫其他区间的最小的数就不能大过MIN+l ,  可以想出假设我们从小到大排序,我们的目的是尽可能的把不满足条件的与满足条件的最大反正一个区间里面.我们可以用sum标记,如果扫描的时候遇到不满足的,sum++,这表示不…
题意: 有n * k块木板,每个木桶由k木板组成,每个木桶的容量定义为它最短的那块木板的长度. 任意两个木桶的容量v1,v2,满足|v1-v2| <= d. 问n个木桶容量的最大的和为多少,或者说明不可能做出这样的n个木桶. 思路: 贪心 要满足|v1-v2| <= d,那么就要满足最大的木桶容量和最小的木桶容量的差小于等于d. 所以先把木板长度排序,如果a[0] 到 a[0] + d这个范围内有大于等于n个木板,那么就存在合理的分配方案,因为可以把至少n个木板作为最短的木板. 然后就计算最大…
You have m = n·k wooden staves. The i-th stave has length ai. You have to assemble nbarrels consisting of k staves each, you can use any k staves to construct a barrel. Each stave must belong to exactly one barrel. Let volume vj of barrel j be equal…
http://codeforces.com/problemset/problem/893/D 题意 Recenlty Luba有一张信用卡可用,一开始金额为0,每天早上可以去充任意数量的钱.到了晚上,银行会对信用卡进行一次操作,操作有三种操作. 1.如果a[i]>0,银行会给卡充入a[i]元. 2.如果a[i]<0 银行从卡中扣除a[i]元. 3.如果a[i]=0 银行会查询卡里的金额. 有两条规则,如果违背信用卡就会被冻结. 1.信用卡里的金额不能大于d. 2.当银行查询卡里的金额时,金额不…
There are n people and k keys on a straight line. Every person wants to get to the office which is located on the line as well. To do that, he needs to reach some point with a key, take the key and then go to the office. Once a key is taken by somebo…
Arkady needs your help again! This time he decided to build his own high-speed Internet exchange point. It should consist of n nodes connected with minimum possible number of wires into one network (a wire directly connects two nodes). Exactly k of t…