c语言sscanf函数的用法是什么
229
2022-09-15
HDU 5777 BestCoder Round #85 domino (多米诺骨牌模拟)
domino
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total Submission(s): 372 Accepted Submission(s): 202
Problem Description
Little White plays a game.There are n pieces of dominoes on the table in a row. He can choose a domino which hasn't fall down for at most k times, let it fall to the left or right. When a domino is toppled, it will knock down the erect domino. On the assumption that all of the tiles are fallen in the end, he can set the height of all dominoes, but he wants to minimize the sum of all dominoes height. The height of every domino is an integer and at least 1.
Input
The first line of input is an integer T ( 1≤T≤10) There are two lines of each test case. The first line has two integer n and k, respectively domino number and the number of opportunities.( 2≤k,n≤100000) The second line has n - 1 integers, the distance of adjacent domino d, 1≤d≤100000
Output
For each testcase, output of a line, the smallest sum of all dominoes height
Sample Input
1 4 2 2 3 4
Sample Output
9
Source
BestCoder Round #85
Recommend
wange2014 | We have carefully selected several similar problems for you: 5780 5779 5778 5775 5774
题意:
桌子上有n张多米诺骨牌排成一列。它有k次机会,每次可以选一个还没有倒的骨牌,向左或者向右推倒。每个骨 牌倒下的时候,若碰到了未倒下的骨牌,可以把它推倒。小白现在可以随意设置骨牌的高度,但是骨牌高度为整数,且至少为1,并且小白希望在能够推倒所有骨牌的前提下,使所有骨牌高度的和最小。
题解: 首先骨牌只要考虑都往右推,其次能带倒骨牌的前提是高度大于等于距离+1。然后模拟一下就可以了。
AC代码:
#include
版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。
发表评论
暂时没有评论,来抢沙发吧~