|
1 |
| -# [1388. Pizza With 3n Slices](https://leetcode.com/problems/pizza-with-3n-slices) |
2 |
| - |
3 |
| -[中文文档](/solution/1300-1399/1388.Pizza%20With%203n%20Slices/README.md) |
4 |
| - |
5 |
| -## Description |
6 |
| - |
7 |
| -<p>There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:</p> |
8 |
| -
|
9 |
| -<ul> |
10 |
| - <li>You will pick <strong>any</strong> pizza slice.</li> |
11 |
| - <li>Your friend Alice will pick next slice in anti clockwise direction of your pick. </li> |
12 |
| - <li>Your friend Bob will pick next slice in clockwise direction of your pick.</li> |
13 |
| - <li>Repeat until there are no more slices of pizzas.</li> |
14 |
| -</ul> |
15 |
| -
|
16 |
| -<p>Sizes of Pizza slices is represented by circular array <code>slices</code> in clockwise direction.</p> |
17 |
| -
|
18 |
| -<p>Return the maximum possible sum of slice sizes which you can have.</p> |
19 |
| -
|
20 |
| -<p> </p> |
21 |
| -<p><strong>Example 1:</strong></p> |
22 |
| -
|
23 |
| -<p><img alt="" src="https://assets.leetcode.com/uploads/2020/02/18/sample_3_1723.png" style="width: 475px; height: 240px;" /></p> |
24 |
| -
|
25 |
| -<pre> |
26 |
| -<strong>Input:</strong> slices = [1,2,3,4,5,6] |
27 |
| -<strong>Output:</strong> 10 |
28 |
| -<strong>Explanation:</strong> Pick pizza slice of size 4, Alice and Bob will pick slices with size 3 and 5 respectively. Then Pick slices with size 6, finally Alice and Bob will pick slice of size 2 and 1 respectively. Total = 4 + 6. |
29 |
| -</pre> |
30 |
| -
|
31 |
| -<p><strong>Example 2:</strong></p> |
32 |
| -
|
33 |
| -<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/02/18/sample_4_1723.png" style="width: 475px; height: 250px;" /></strong></p> |
34 |
| -
|
35 |
| -<pre> |
36 |
| -<strong>Input:</strong> slices = [8,9,8,6,1,1] |
37 |
| -<strong>Output:</strong> 16 |
38 |
| -<strong>Output:</strong> Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8. |
39 |
| -</pre> |
40 |
| -
|
41 |
| -<p><strong>Example 3:</strong></p> |
42 |
| -
|
43 |
| -<pre> |
44 |
| -<strong>Input:</strong> slices = [4,1,2,5,8,3,1,9,7] |
45 |
| -<strong>Output:</strong> 21 |
46 |
| -</pre> |
47 |
| -
|
48 |
| -<p><strong>Example 4:</strong></p> |
49 |
| -
|
50 |
| -<pre> |
51 |
| -<strong>Input:</strong> slices = [3,1,2] |
52 |
| -<strong>Output:</strong> 3 |
53 |
| -</pre> |
54 |
| -
|
55 |
| -<p> </p> |
56 |
| -<p><strong>Constraints:</strong></p> |
57 |
| -
|
58 |
| -<ul> |
59 |
| - <li><code>1 <= slices.length <= 500</code></li> |
60 |
| - <li><code>slices.length % 3 == 0</code></li> |
61 |
| - <li><code>1 <= slices[i] <= 1000</code></li> |
62 |
| -</ul> |
63 |
| - |
64 |
| -## Solutions |
65 |
| - |
66 |
| - |
67 |
| - |
68 |
| -<!-- tabs:start --> |
69 |
| - |
70 |
| -### **Python3** |
71 |
| - |
72 |
| - |
73 |
| -```python |
74 |
| - |
75 |
| -``` |
76 |
| - |
77 |
| -### **Java** |
78 |
| - |
79 |
| - |
80 |
| -```java |
81 |
| - |
82 |
| -``` |
83 |
| - |
84 |
| -### **...** |
85 |
| -``` |
86 |
| - |
87 |
| -``` |
88 |
| - |
| 1 | +# [1388. Pizza With 3n Slices](https://leetcode.com/problems/pizza-with-3n-slices) |
| 2 | + |
| 3 | +[中文文档](/solution/1300-1399/1388.Pizza%20With%203n%20Slices/README.md) |
| 4 | + |
| 5 | +## Description |
| 6 | + |
| 7 | +<p>There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:</p> |
| 8 | + |
| 9 | + |
| 10 | + |
| 11 | +<ul> |
| 12 | + |
| 13 | + <li>You will pick <strong>any</strong> pizza slice.</li> |
| 14 | + |
| 15 | + <li>Your friend Alice will pick next slice in anti clockwise direction of your pick. </li> |
| 16 | + |
| 17 | + <li>Your friend Bob will pick next slice in clockwise direction of your pick.</li> |
| 18 | + |
| 19 | + <li>Repeat until there are no more slices of pizzas.</li> |
| 20 | + |
| 21 | +</ul> |
| 22 | + |
| 23 | + |
| 24 | + |
| 25 | +<p>Sizes of Pizza slices is represented by circular array <code>slices</code> in clockwise direction.</p> |
| 26 | + |
| 27 | + |
| 28 | + |
| 29 | +<p>Return the maximum possible sum of slice sizes which you can have.</p> |
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | +<p> </p> |
| 34 | + |
| 35 | +<p><strong>Example 1:</strong></p> |
| 36 | + |
| 37 | + |
| 38 | + |
| 39 | + |
| 40 | +<pre> |
| 41 | + |
| 42 | +<strong>Input:</strong> slices = [1,2,3,4,5,6] |
| 43 | + |
| 44 | +<strong>Output:</strong> 10 |
| 45 | + |
| 46 | +<strong>Explanation:</strong> Pick pizza slice of size 4, Alice and Bob will pick slices with size 3 and 5 respectively. Then Pick slices with size 6, finally Alice and Bob will pick slice of size 2 and 1 respectively. Total = 4 + 6. |
| 47 | + |
| 48 | +</pre> |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +<p><strong>Example 2:</strong></p> |
| 53 | + |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +<pre> |
| 60 | + |
| 61 | +<strong>Input:</strong> slices = [8,9,8,6,1,1] |
| 62 | + |
| 63 | +<strong>Output:</strong> 16 |
| 64 | + |
| 65 | +<strong>Output:</strong> Pick pizza slice of size 8 in each turn. If you pick slice with size 9 your partners will pick slices of size 8. |
| 66 | + |
| 67 | +</pre> |
| 68 | + |
| 69 | + |
| 70 | + |
| 71 | +<p><strong>Example 3:</strong></p> |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | +<pre> |
| 76 | + |
| 77 | +<strong>Input:</strong> slices = [4,1,2,5,8,3,1,9,7] |
| 78 | + |
| 79 | +<strong>Output:</strong> 21 |
| 80 | + |
| 81 | +</pre> |
| 82 | + |
| 83 | + |
| 84 | + |
| 85 | +<p><strong>Example 4:</strong></p> |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | +<pre> |
| 90 | + |
| 91 | +<strong>Input:</strong> slices = [3,1,2] |
| 92 | + |
| 93 | +<strong>Output:</strong> 3 |
| 94 | + |
| 95 | +</pre> |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | +<p> </p> |
| 100 | + |
| 101 | +<p><strong>Constraints:</strong></p> |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +<ul> |
| 106 | + <li><code>1 <= slices.length <= 500</code></li> |
| 107 | + <li><code>slices.length % 3 == 0</code></li> |
| 108 | + <li><code>1 <= slices[i] <= 1000</code></li> |
| 109 | +</ul> |
| 110 | + |
| 111 | +## Solutions |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +<!-- tabs:start --> |
| 116 | + |
| 117 | +### **Python3** |
| 118 | + |
| 119 | + |
| 120 | +```python |
| 121 | + |
| 122 | +``` |
| 123 | + |
| 124 | +### **Java** |
| 125 | + |
| 126 | + |
| 127 | +```java |
| 128 | + |
| 129 | +``` |
| 130 | + |
| 131 | +### **...** |
| 132 | +``` |
| 133 | +
|
| 134 | +``` |
| 135 | + |
89 | 136 | <!-- tabs:end -->
|
0 commit comments