排个序,求前k个元素和即可
int minimum(int K, vector <int> danceCost) { sort(danceCost.begin(),danceCost.end()); return accumulate(danceCost.begin(),danceCost.begin()+K,0); }
topcoder SRM 624 DIV2 CostOfDancing,布布扣,bubuko.com
topcoder SRM 624 DIV2 CostOfDancing
原文地址:http://www.cnblogs.com/xiongqiangcs/p/3785424.html