贪心
WeSeewe_Wy
这个作者很懒,什么都没留下…
展开
-
CSU1588 合并果子(贪心)
题目:现在有n堆果子,第i堆有ai个果子。现在要把这些果子合并成一堆,每次合并的代价是两堆果子的总果子数。求合并所有果子的最小代价。 思路:每次优先合并最小的两堆,但若每次合并后都进行排序,会造成TE,本文采取冒泡排序,每次只排出最小的两个。 代码如下:#include #include using namespace std; int T,n,a[1100],s; int main()原创 2017-02-12 14:09:05 · 503 阅读 · 0 评论 -
HDU1051 Wooden Sticks
题目: There is a pile of n wooden sticks. The length and weight of each stick are known in advance. The sticks are to be processed by a woodworking machine in one by one fashion. It needs some time, ca原创 2017-02-13 16:33:56 · 258 阅读 · 0 评论 -
CSU - 1270 Swap Digit (贪心)
Description Now we have a number, you can swap any two adjacent digits of it, but you can not swap more than K times. Then, what is the largest probable number that we can get after your swapping? I...原创 2018-05-13 16:30:49 · 253 阅读 · 0 评论