很有趣的一道归纳贪心题目
class Solution {
public:
int minimumAddedCoins(vector<int>& coins, int target) {
sort(coins.begin(),coins.end());
int n = coins.size();
int s = 0,i=0;
int res = 0;
while(s<target){
if(i<n&&coins[i]<=s+1)s+=coins[i++];
else{
s= s+s+1;
res++;
}
}
return res;
}
};