2023-09-20力扣每日一题-水题

链接:

LCP 06. 拿硬币

题意

打家劫舍完,就要拿你硬币了!

每一堆需要(Coins[I]+1)/2

实际代码:

#include
using namespace std;
int minCount(vector& coins)
{
	int ans=0;
	
	for(int coin:coins)
	{
		ans+=(coin+1)/2;
	}
	
	return ans;
}

限制:

  • 1 <= n <= 4
  • 1 <= coins[i] <= 10

你可能感兴趣的:(力扣每日一题,leetcode)