Maximum Score From Removing Stones
给三个数, a,b,c, 每次拿两个数并且-1, 算一分, 求最大能得多少分.
贪婪算法, 想下肯定是最多的两个堆拿的结果是最多的. 所以题目转化成从abc中不断找到最大的两个数.
class Solution {
int res = 0;
public int maximumScore(int a, int b, int c) {
int d = a + b + c;
if(d == a || d == b || d == c)
return res;
int[] tmp = new int[3];
tmp[0] = a;
tmp[1] = b;
tmp[2] = c;
Arrays.sort(tmp);
res++;
return maximumScore(tmp[2] - 1, tmp[1] - 1, tmp[0]);
}
}