|
1 | 1 | # [1753.Maximum Score From Removing Stones][title] |
2 | 2 |
|
3 | | -> [!WARNING|style:flat] |
4 | | -> This question is temporarily unanswered if you have good ideas. Welcome to [Create Pull Request PR](https://github.com/kylesliu/awesome-golang-algorithm) |
5 | | -
|
6 | 3 | ## Description |
| 4 | +You are playing a solitaire game with **three piles** of stones of sizes `a`, `b`, `c` respectively. Each turn you choose two **different non-empty** piles, take one stone from each, and add `1` point to your score. The game stops when there are **fewer than two non-empty** piles (meaning there are no more available moves). |
| 5 | + |
| 6 | +Given three integers `a`, `b`, and `c` return the **maximum score** you can get. |
7 | 7 |
|
8 | 8 | **Example 1:** |
9 | 9 |
|
10 | 10 | ``` |
11 | | -Input: a = "11", b = "1" |
12 | | -Output: "100" |
| 11 | +Input: a = 2, b = 4, c = 6 |
| 12 | +Output: 6 |
| 13 | +Explanation: The starting state is (2, 4, 6). One optimal set of moves is: |
| 14 | +- Take from 1st and 3rd piles, state is now (1, 4, 5) |
| 15 | +- Take from 1st and 3rd piles, state is now (0, 4, 4) |
| 16 | +- Take from 2nd and 3rd piles, state is now (0, 3, 3) |
| 17 | +- Take from 2nd and 3rd piles, state is now (0, 2, 2) |
| 18 | +- Take from 2nd and 3rd piles, state is now (0, 1, 1) |
| 19 | +- Take from 2nd and 3rd piles, state is now (0, 0, 0) |
| 20 | +There are fewer than two non-empty piles, so the game ends. Total: 6 points. |
13 | 21 | ``` |
14 | 22 |
|
15 | | -## 题意 |
16 | | -> ... |
| 23 | +**Example 2:** |
17 | 24 |
|
18 | | -## 题解 |
19 | | - |
20 | | -### 思路1 |
21 | | -> ... |
22 | | -Maximum Score From Removing Stones |
23 | | -```go |
| 25 | +``` |
| 26 | +Input: a = 4, b = 4, c = 6 |
| 27 | +Output: 7 |
| 28 | +Explanation: The starting state is (4, 4, 6). One optimal set of moves is: |
| 29 | +- Take from 1st and 2nd piles, state is now (3, 3, 6) |
| 30 | +- Take from 1st and 3rd piles, state is now (2, 3, 5) |
| 31 | +- Take from 1st and 3rd piles, state is now (1, 3, 4) |
| 32 | +- Take from 1st and 3rd piles, state is now (0, 3, 3) |
| 33 | +- Take from 2nd and 3rd piles, state is now (0, 2, 2) |
| 34 | +- Take from 2nd and 3rd piles, state is now (0, 1, 1) |
| 35 | +- Take from 2nd and 3rd piles, state is now (0, 0, 0) |
| 36 | +There are fewer than two non-empty piles, so the game ends. Total: 7 points. |
24 | 37 | ``` |
25 | 38 |
|
| 39 | +**Example 3:** |
| 40 | + |
| 41 | +``` |
| 42 | +Input: a = 1, b = 8, c = 8 |
| 43 | +Output: 8 |
| 44 | +Explanation: One optimal set of moves is to take from the 2nd and 3rd piles for 8 turns until they are empty. |
| 45 | +After that, there are fewer than two non-empty piles, so the game ends. |
| 46 | +``` |
26 | 47 |
|
27 | 48 | ## 结语 |
28 | 49 |
|
|
0 commit comments