java.lang.Object
g1701_1800.s1753_maximum_score_from_removing_stones.Solution

public class Solution extends Object
1753 - Maximum Score From Removing Stones.<p>Medium</p> <p>You are playing a solitaire game with <strong>three piles</strong> of stones of sizes <code>a</code>, <code>b</code>, and <code>c</code> respectively. Each turn you choose two <strong>different non-empty</strong> piles, take one stone from each, and add <code>1</code> point to your score. The game stops when there are <strong>fewer than two non-empty</strong> piles (meaning there are no more available moves).</p> <p>Given three integers <code>a</code>, <code>b</code>, and <code>c</code>, return <em>the</em> <strong><em>maximum</em></strong> <em><strong>score</strong> you can get.</em></p> <p><strong>Example 1:</strong></p> <p><strong>Input:</strong> a = 2, b = 4, c = 6</p> <p><strong>Output:</strong> 6</p> <p><strong>Explanation:</strong> The starting state is (2, 4, 6). One optimal set of moves is:</p> <ul> <li> <p>Take from 1st and 3rd piles, state is now (1, 4, 5)</p> </li> <li> <p>Take from 1st and 3rd piles, state is now (0, 4, 4)</p> </li> <li> <p>Take from 2nd and 3rd piles, state is now (0, 3, 3)</p> </li> <li> <p>Take from 2nd and 3rd piles, state is now (0, 2, 2)</p> </li> <li> <p>Take from 2nd and 3rd piles, state is now (0, 1, 1)</p> </li> <li> <p>Take from 2nd and 3rd piles, state is now (0, 0, 0)</p> </li> </ul> <p>There are fewer than two non-empty piles, so the game ends. Total: 6 points.</p> <p><strong>Example 2:</strong></p> <p><strong>Input:</strong> a = 4, b = 4, c = 6</p> <p><strong>Output:</strong> 7</p> <p><strong>Explanation:</strong> The starting state is (4, 4, 6). One optimal set of moves is:</p> <ul> <li> <p>Take from 1st and 2nd piles, state is now (3, 3, 6)</p> </li> <li> <p>Take from 1st and 3rd piles, state is now (2, 3, 5)</p> </li> <li> <p>Take from 1st and 3rd piles, state is now (1, 3, 4)</p> </li> <li> <p>Take from 1st and 3rd piles, state is now (0, 3, 3)</p> </li> <li> <p>Take from 2nd and 3rd piles, state is now (0, 2, 2)</p> </li> <li> <p>Take from 2nd and 3rd piles, state is now (0, 1, 1)</p> </li> <li> <p>Take from 2nd and 3rd piles, state is now (0, 0, 0)</p> </li> </ul> <p>There are fewer than two non-empty piles, so the game ends. Total: 7 points.</p> <p><strong>Example 3:</strong></p> <p><strong>Input:</strong> a = 1, b = 8, c = 8</p> <p><strong>Output:</strong> 8</p> <p><strong>Explanation:</strong> One optimal set of moves is to take from the 2nd and 3rd piles for 8 turns until they are empty. After that, there are fewer than two non-empty piles, so the game ends.</p> <p><strong>Constraints:</strong></p> <ul> <li><code>1 <= a, b, c <= 10<sup>5</sup></code></li> </ul>
  • Constructor Details

    • Solution

      public Solution()
  • Method Details

    • maximumScore

      public int maximumScore(int a, int b, int c)