Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions solution/1300-1399/1386.Cinema Seat Allocation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
## 题目描述

<!-- 这里写题目描述 -->
<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/03/21/cinema_seats_1.png" style="height: 149px; width: 400px;"></p>

![](./images/cinema_seats_1.png)

<p>如上图所示,电影院的观影厅中有 <code>n</code>&nbsp;行座位,行编号从 1&nbsp;到 <code>n</code>&nbsp;,且每一行内总共有 10 个座位,列编号从 1 到 10 。</p>

Expand All @@ -17,7 +18,7 @@

<p><strong>示例 1:</strong></p>

<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/03/21/cinema_seats_3.png" style="height: 96px; width: 400px;"></p>
![](./images/cinema_seats_3.png)

<pre><strong>输入:</strong>n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]
<strong>输出:</strong>4
Expand Down
4 changes: 2 additions & 2 deletions solution/1300-1399/1386.Cinema Seat Allocation/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## Description

<p><img alt="" src="https://assets.leetcode.com/uploads/2020/02/14/cinema_seats_1.png" style="width: 400px; height: 149px;" /></p>
![](./images/cinema_seats_1.png)

<p>A cinema&nbsp;has <code>n</code>&nbsp;rows of seats, numbered from 1 to <code>n</code>&nbsp;and there are ten&nbsp;seats in each row, labelled from 1&nbsp;to 10&nbsp;as shown in the figure above.</p>

Expand All @@ -15,7 +15,7 @@
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<p><img alt="" src="https://assets.leetcode.com/uploads/2020/02/14/cinema_seats_3.png" style="width: 400px; height: 96px;" /></p>
![](./images/cinema_seats_3.png)

<pre>
<strong>Input:</strong> n = 3, reservedSeats = [[1,2],[1,3],[1,8],[2,6],[3,1],[3,10]]
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions solution/1300-1399/1388.Pizza With 3n Slices/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

<p><strong>示例 1:</strong></p>

<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/03/21/sample_3_1723.png" style="height: 240px; width: 475px;"></p>
![](./images/sample_3_1723.png)

<pre><strong>输入:</strong>slices = [1,2,3,4,5,6]
<strong>输出:</strong>10
Expand All @@ -31,7 +31,7 @@

<p><strong>示例 2:</strong></p>

<p><strong><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/03/21/sample_4_1723.png" style="height: 250px; width: 475px;"></strong></p>
![](./images/sample_4_1723.png)

<pre><strong>输入:</strong>slices = [8,9,8,6,1,1]
<strong>输出:</strong>16
Expand Down
223 changes: 135 additions & 88 deletions solution/1300-1399/1388.Pizza With 3n Slices/README_EN.md
Original file line number Diff line number Diff line change
@@ -1,89 +1,136 @@
# [1388. Pizza With 3n Slices](https://leetcode.com/problems/pizza-with-3n-slices)

[中文文档](/solution/1300-1399/1388.Pizza%20With%203n%20Slices/README.md)

## Description

<p>There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:</p>

<ul>
<li>You will pick <strong>any</strong> pizza slice.</li>
<li>Your friend Alice&nbsp;will pick&nbsp;next slice in anti clockwise direction of your pick.&nbsp;</li>
<li>Your friend Bob&nbsp;will&nbsp;pick&nbsp;next slice in clockwise direction of your pick.</li>
<li>Repeat&nbsp;until&nbsp;there are no more slices of pizzas.</li>
</ul>

<p>Sizes of Pizza slices is represented by circular array <code>slices</code> in clockwise direction.</p>

<p>Return the maximum possible sum of slice sizes which you can have.</p>

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<p><img alt="" src="https://assets.leetcode.com/uploads/2020/02/18/sample_3_1723.png" style="width: 475px; height: 240px;" /></p>

<pre>
<strong>Input:</strong> slices = [1,2,3,4,5,6]
<strong>Output:</strong> 10
<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.
</pre>

<p><strong>Example 2:</strong></p>

<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/02/18/sample_4_1723.png" style="width: 475px; height: 250px;" /></strong></p>

<pre>
<strong>Input:</strong> slices = [8,9,8,6,1,1]
<strong>Output:</strong> 16
<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.
</pre>

<p><strong>Example 3:</strong></p>

<pre>
<strong>Input:</strong> slices = [4,1,2,5,8,3,1,9,7]
<strong>Output:</strong> 21
</pre>

<p><strong>Example 4:</strong></p>

<pre>
<strong>Input:</strong> slices = [3,1,2]
<strong>Output:</strong> 3
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
<li><code>1 &lt;= slices.length &lt;= 500</code></li>
<li><code>slices.length % 3 == 0</code></li>
<li><code>1 &lt;= slices[i] &lt;= 1000</code></li>
</ul>

## Solutions



<!-- tabs:start -->

### **Python3**


```python

```

### **Java**


```java

```

### **...**
```

```

# [1388. Pizza With 3n Slices](https://leetcode.com/problems/pizza-with-3n-slices)

[中文文档](/solution/1300-1399/1388.Pizza%20With%203n%20Slices/README.md)

## Description

<p>There is a pizza with 3n slices of varying size, you and your friends will take slices of pizza as follows:</p>



<ul>

<li>You will pick <strong>any</strong> pizza slice.</li>

<li>Your friend Alice&nbsp;will pick&nbsp;next slice in anti clockwise direction of your pick.&nbsp;</li>

<li>Your friend Bob&nbsp;will&nbsp;pick&nbsp;next slice in clockwise direction of your pick.</li>

<li>Repeat&nbsp;until&nbsp;there are no more slices of pizzas.</li>

</ul>



<p>Sizes of Pizza slices is represented by circular array <code>slices</code> in clockwise direction.</p>



<p>Return the maximum possible sum of slice sizes which you can have.</p>



<p>&nbsp;</p>

<p><strong>Example 1:</strong></p>


![](./images/sample_3_1723.png)

<pre>

<strong>Input:</strong> slices = [1,2,3,4,5,6]

<strong>Output:</strong> 10

<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.

</pre>



<p><strong>Example 2:</strong></p>


![](./images/sample_4_1723.png)



<pre>

<strong>Input:</strong> slices = [8,9,8,6,1,1]

<strong>Output:</strong> 16

<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.

</pre>



<p><strong>Example 3:</strong></p>



<pre>

<strong>Input:</strong> slices = [4,1,2,5,8,3,1,9,7]

<strong>Output:</strong> 21

</pre>



<p><strong>Example 4:</strong></p>



<pre>

<strong>Input:</strong> slices = [3,1,2]

<strong>Output:</strong> 3

</pre>



<p>&nbsp;</p>

<p><strong>Constraints:</strong></p>



<ul>
<li><code>1 &lt;= slices.length &lt;= 500</code></li>
<li><code>slices.length % 3 == 0</code></li>
<li><code>1 &lt;= slices[i] &lt;= 1000</code></li>
</ul>

## Solutions



<!-- tabs:start -->

### **Python3**


```python

```

### **Java**


```java

```

### **...**
```

```

<!-- tabs:end -->
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
<li><strong>6</strong> 表示连接右单元格和上单元格的街道。</li>
</ul>

<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/03/21/main.png" style="height: 708px; width: 450px;"></p>
![](./images/main.png)

<p>你最开始从左上角的单元格 <code>(0,0)</code> 开始出发,网格中的「有效路径」是指从左上方的单元格 <code>(0,0)</code> 开始、一直到右下方的 <code>(m-1,n-1)</code> 结束的路径。<strong>该路径必须只沿着街道走</strong>。</p>

Expand All @@ -28,7 +28,7 @@

<p><strong>示例 1:</strong></p>

<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/03/21/e1.png" style="height: 311px; width: 455px;"></p>
![](./images/e1.png)

<pre><strong>输入:</strong>grid = [[2,4,3],[6,5,2]]
<strong>输出:</strong>true
Expand All @@ -37,7 +37,7 @@

<p><strong>示例 2:</strong></p>

<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/03/21/e2.png" style="height: 293px; width: 455px;"></p>
![](./images/e2.png)

<pre><strong>输入:</strong>grid = [[1,2,1],[1,2,1]]
<strong>输出:</strong>false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Given a <em>m</em> x <em>n</em> <code>grid</code>. Each cell of the <code>grid</
<li><b>6</b> which means a street connecting the right cell and the upper cell.</li>
</ul>

<p><img alt="" src="https://assets.leetcode.com/uploads/2020/03/05/main.png" style="width: 450px; height: 708px;" /></p>
![](./images/main.png)

<p>You will initially start at the street of the&nbsp;upper-left cell <code>(0,0)</code>. A valid path in the grid is a path which starts from the upper left&nbsp;cell <code>(0,0)</code> and ends at the bottom-right&nbsp;cell <code>(m - 1, n - 1)</code>. <strong>The path should only follow the streets</strong>.</p>

Expand All @@ -24,15 +24,19 @@ Given a <em>m</em> x <em>n</em> <code>grid</code>. Each cell of the <code>grid</

<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/03/05/e1.png" style="width: 455px; height: 311px;" />

![](./images/e1.png)

<pre>
<strong>Input:</strong> grid = [[2,4,3],[6,5,2]]
<strong>Output:</strong> true
<strong>Explanation:</strong> As shown you can start at cell (0, 0) and visit all the cells of the grid to reach (m - 1, n - 1).
</pre>

<p><strong>Example 2:</strong></p>
<img alt="" src="https://assets.leetcode.com/uploads/2020/03/05/e2.png" style="width: 455px; height: 293px;" />

![](./images/e2.png)

<pre>
<strong>Input:</strong> grid = [[1,2,1],[1,2,1]]
<strong>Output:</strong> false
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<p><strong>示例 1:</strong></p>

<p><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/04/04/sample_4_1728.png" style="height: 167px; width: 258px;"></p>
![](./images/sample_4_1728.png)

<pre><strong>输入:</strong>radius = 1, x_center = 0, y_center = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
<strong>输出:</strong>true
Expand All @@ -24,15 +24,15 @@

<p><strong>示例 2:</strong></p>

<p><strong><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/04/04/sample_2_1728.png" style="height: 135px; width: 150px;"></strong></p>
![](./images/sample_2_1728.png)

<pre><strong>输入:</strong>radius = 1, x_center = 0, y_center = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
<strong>输出:</strong>true
</pre>

<p><strong>示例 3:</strong></p>

<p><strong><img alt="" src="https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/04/04/sample_6_1728.png" style="height: 165px; width: 175px;"></strong></p>
![](./images/sample_6_1728.png)

<pre><strong>输入:</strong>radius = 1, x_center = 1, y_center = 1, x1 = -3, y1 = -3, x2 = 3, y2 = 3
<strong>输出:</strong>true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<p>&nbsp;</p>
<p><strong>Example 1:</strong></p>

<p><img alt="" src="https://assets.leetcode.com/uploads/2020/02/20/sample_4_1728.png" style="width: 258px; height: 167px;" /></p>
![](./images/sample_4_1728.png)

<pre>
<strong>Input:</strong> radius = 1, x_center = 0, y_center = 0, x1 = 1, y1 = -1, x2 = 3, y2 = 1
Expand All @@ -23,7 +23,7 @@

<p><strong>Example 2:</strong></p>

<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/02/20/sample_2_1728.png" style="width: 150px; height: 135px;" /></strong></p>
![](./images/sample_2_1728.png)

<pre>
<strong>Input:</strong> radius = 1, x_center = 0, y_center = 0, x1 = -1, y1 = 0, x2 = 0, y2 = 1
Expand All @@ -32,7 +32,7 @@

<p><strong>Example 3:</strong></p>

<p><strong><img alt="" src="https://assets.leetcode.com/uploads/2020/03/03/sample_6_1728.png" style="width: 175px; height: 165px;" /></strong></p>
![](./images/sample_6_1728.png)

<pre>
<strong>Input:</strong> radius = 1, x_center = 1, y_center = 1, x1 = -3, y1 = -3, x2 = 3, y2 = 3
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading