注意题目这句话,Once you have each type of candies in a box, you want to pack those boxes into larger boxes, until only one box remains. 两个box合并后必须放入更大一个盒子 题目的有点类似huffman的前部分,此题用堆去做,由于priority_queue是用堆实现的,故可以直接使用 每次从堆中选取最小的两个进行合并即可 #include <iostream> #incl…
周赛时遇到的一道比较有意思的题目: Problem Statement There are N rooms in Maki's new house. The rooms are numbered from 0 to N-1. Some pairs of rooms are connected by bidirectional passages. The passages have the topology of a tree. That is, there are exactly N-…
题目比较简单. 注意看测试用例2,给的提示 Please note that this is the largest possible return value: whenever there is a solution, there is a solution that uses at most two moves. 最多只有两步 #include <vector> #include <string> #include <list> #include <map&…