Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 59e6d15

Browse files
chore: update lc problems (doocs#4317)
1 parent 2a5efa4 commit 59e6d15

File tree

4 files changed

+240
-0
lines changed

4 files changed

+240
-0
lines changed
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
comments: true
3+
difficulty: 困难
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3506.Find%20Time%20Required%20to%20Eliminate%20Bacterial%20Strains%20II/README.md
5+
---
6+
7+
<!-- problem:start -->
8+
9+
# [3506. Find Time Required to Eliminate Bacterial Strains II 🔒](https://leetcode.cn/problems/find-time-required-to-eliminate-bacterial-strains-ii)
10+
11+
[English Version](/solution/3500-3599/3506.Find%20Time%20Required%20to%20Eliminate%20Bacterial%20Strains%20II/README_EN.md)
12+
13+
## 题目描述
14+
15+
<!-- description:start -->
16+
17+
<p>You are given an integer array <code>timeReq</code> and an integer <code>splitTime</code>.</p>
18+
19+
<p>In the microscopic world of the human body, the immune system faces an extraordinary challenge: combatting a rapidly multiplying bacterial colony that threatens the body&#39;s survival.</p>
20+
21+
<p>Initially, only one <strong>white blood cell</strong> (<strong>WBC</strong>) is deployed to eliminate the bacteria. However, the lone WBC quickly realizes it cannot keep up with the bacterial growth rate.</p>
22+
23+
<p>The WBC devises a clever strategy to fight the bacteria:</p>
24+
25+
<ul>
26+
<li>The <code>i<sup>th</sup></code> bacterial strain takes <code>timeReq[i]</code> units of time to be eliminated.</li>
27+
<li>A single WBC can eliminate <strong>only one</strong> bacterial strain. Afterwards, the WBC is exhausted and cannot perform any other tasks.</li>
28+
<li>A WBC can split itself into two WBCs, but this requires <code>splitTime</code> units of time. Once split, the two WBCs can work in <strong>parallel</strong> on eliminating the bacteria.</li>
29+
<li><em>Only one</em> WBC can work on a single bacterial strain. Multiple WBCs <strong>cannot</strong> attack one strain in parallel.</li>
30+
</ul>
31+
32+
<p>You must determine the <strong>minimum</strong> time required to eliminate all the bacterial strains.</p>
33+
34+
<p><strong>Note</strong> that the bacterial strains can be eliminated in any order.</p>
35+
36+
<p>&nbsp;</p>
37+
<p><strong class="example">Example 1:</strong></p>
38+
39+
<div class="example-block">
40+
<p><strong>Input:</strong> <span class="example-io">timeReq = [10,4,5], splitTime = 2</span></p>
41+
42+
<p><strong>Output:</strong> <span class="example-io">12</span></p>
43+
44+
<p><strong>Explanation:</strong></p>
45+
46+
<p>The elimination process goes as follows:</p>
47+
48+
<ul>
49+
<li>Initially, there is a single WBC. The WBC splits into 2 WBCs after 2 units of time.</li>
50+
<li>One of the WBCs eliminates strain 0 at a time <code>t = 2 + 10 = 12.</code> The other WBC splits again, using 2 units of time.</li>
51+
<li>The 2 new WBCs eliminate the bacteria at times <code>t = 2 + 2 + 4</code> and <code>t = 2 + 2 + 5</code>.</li>
52+
</ul>
53+
</div>
54+
55+
<p><strong class="example">Example 2:</strong></p>
56+
57+
<div class="example-block">
58+
<p><strong>Input:</strong> <span class="example-io">timeReq = [10,4], splitTime = 5</span></p>
59+
60+
<p><strong>Output:</strong>15</p>
61+
62+
<p><strong>Explanation:</strong></p>
63+
64+
<p>The elimination process goes as follows:</p>
65+
66+
<ul>
67+
<li>Initially, there is a single WBC. The WBC splits into 2 WBCs after 5 units of time.</li>
68+
<li>The 2 new WBCs eliminate the bacteria at times <code>t = 5 + 10</code> and <code>t = 5 + 4</code>.</li>
69+
</ul>
70+
</div>
71+
72+
<p>&nbsp;</p>
73+
<p><strong>Constraints:</strong></p>
74+
75+
<ul>
76+
<li><code>2 &lt;= timeReq.length &lt;= 10<sup>5</sup></code></li>
77+
<li><code>1 &lt;= timeReq[i] &lt;= 10<sup>9</sup></code></li>
78+
<li><code>1 &lt;= splitTime &lt;= 10<sup>9</sup></code></li>
79+
</ul>
80+
81+
<!-- description:end -->
82+
83+
## 解法
84+
85+
<!-- solution:start -->
86+
87+
### 方法一
88+
89+
<!-- tabs:start -->
90+
91+
#### Python3
92+
93+
```python
94+
95+
```
96+
97+
#### Java
98+
99+
```java
100+
101+
```
102+
103+
#### C++
104+
105+
```cpp
106+
107+
```
108+
109+
#### Go
110+
111+
```go
112+
113+
```
114+
115+
<!-- tabs:end -->
116+
117+
<!-- solution:end -->
118+
119+
<!-- problem:end -->
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
---
2+
comments: true
3+
difficulty: Hard
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3500-3599/3506.Find%20Time%20Required%20to%20Eliminate%20Bacterial%20Strains%20II/README_EN.md
5+
---
6+
7+
<!-- problem:start -->
8+
9+
# [3506. Find Time Required to Eliminate Bacterial Strains II 🔒](https://leetcode.com/problems/find-time-required-to-eliminate-bacterial-strains-ii)
10+
11+
[中文文档](/solution/3500-3599/3506.Find%20Time%20Required%20to%20Eliminate%20Bacterial%20Strains%20II/README.md)
12+
13+
## Description
14+
15+
<!-- description:start -->
16+
17+
<p>You are given an integer array <code>timeReq</code> and an integer <code>splitTime</code>.</p>
18+
19+
<p>In the microscopic world of the human body, the immune system faces an extraordinary challenge: combatting a rapidly multiplying bacterial colony that threatens the body&#39;s survival.</p>
20+
21+
<p>Initially, only one <strong>white blood cell</strong> (<strong>WBC</strong>) is deployed to eliminate the bacteria. However, the lone WBC quickly realizes it cannot keep up with the bacterial growth rate.</p>
22+
23+
<p>The WBC devises a clever strategy to fight the bacteria:</p>
24+
25+
<ul>
26+
<li>The <code>i<sup>th</sup></code> bacterial strain takes <code>timeReq[i]</code> units of time to be eliminated.</li>
27+
<li>A single WBC can eliminate <strong>only one</strong> bacterial strain. Afterwards, the WBC is exhausted and cannot perform any other tasks.</li>
28+
<li>A WBC can split itself into two WBCs, but this requires <code>splitTime</code> units of time. Once split, the two WBCs can work in <strong>parallel</strong> on eliminating the bacteria.</li>
29+
<li><em>Only one</em> WBC can work on a single bacterial strain. Multiple WBCs <strong>cannot</strong> attack one strain in parallel.</li>
30+
</ul>
31+
32+
<p>You must determine the <strong>minimum</strong> time required to eliminate all the bacterial strains.</p>
33+
34+
<p><strong>Note</strong> that the bacterial strains can be eliminated in any order.</p>
35+
36+
<p>&nbsp;</p>
37+
<p><strong class="example">Example 1:</strong></p>
38+
39+
<div class="example-block">
40+
<p><strong>Input:</strong> <span class="example-io">timeReq = [10,4,5], splitTime = 2</span></p>
41+
42+
<p><strong>Output:</strong> <span class="example-io">12</span></p>
43+
44+
<p><strong>Explanation:</strong></p>
45+
46+
<p>The elimination process goes as follows:</p>
47+
48+
<ul>
49+
<li>Initially, there is a single WBC. The WBC splits into 2 WBCs after 2 units of time.</li>
50+
<li>One of the WBCs eliminates strain 0 at a time <code>t = 2 + 10 = 12.</code> The other WBC splits again, using 2 units of time.</li>
51+
<li>The 2 new WBCs eliminate the bacteria at times <code>t = 2 + 2 + 4</code> and <code>t = 2 + 2 + 5</code>.</li>
52+
</ul>
53+
</div>
54+
55+
<p><strong class="example">Example 2:</strong></p>
56+
57+
<div class="example-block">
58+
<p><strong>Input:</strong> <span class="example-io">timeReq = [10,4], splitTime = 5</span></p>
59+
60+
<p><strong>Output:</strong>15</p>
61+
62+
<p><strong>Explanation:</strong></p>
63+
64+
<p>The elimination process goes as follows:</p>
65+
66+
<ul>
67+
<li>Initially, there is a single WBC. The WBC splits into 2 WBCs after 5 units of time.</li>
68+
<li>The 2 new WBCs eliminate the bacteria at times <code>t = 5 + 10</code> and <code>t = 5 + 4</code>.</li>
69+
</ul>
70+
</div>
71+
72+
<p>&nbsp;</p>
73+
<p><strong>Constraints:</strong></p>
74+
75+
<ul>
76+
<li><code>2 &lt;= timeReq.length &lt;= 10<sup>5</sup></code></li>
77+
<li><code>1 &lt;= timeReq[i] &lt;= 10<sup>9</sup></code></li>
78+
<li><code>1 &lt;= splitTime &lt;= 10<sup>9</sup></code></li>
79+
</ul>
80+
81+
<!-- description:end -->
82+
83+
## Solutions
84+
85+
<!-- solution:start -->
86+
87+
### Solution 1
88+
89+
<!-- tabs:start -->
90+
91+
#### Python3
92+
93+
```python
94+
95+
```
96+
97+
#### Java
98+
99+
```java
100+
101+
```
102+
103+
#### C++
104+
105+
```cpp
106+
107+
```
108+
109+
#### Go
110+
111+
```go
112+
113+
```
114+
115+
<!-- tabs:end -->
116+
117+
<!-- solution:end -->
118+
119+
<!-- problem:end -->

‎solution/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3516,6 +3516,7 @@
35163516
| 3503 | [子字符串连接后的最长回文串 I](/solution/3500-3599/3503.Longest%20Palindrome%20After%20Substring%20Concatenation%20I/README.md) | | 中等 | 第 443 场周赛 |
35173517
| 3504 | [子字符串连接后的最长回文串 II](/solution/3500-3599/3504.Longest%20Palindrome%20After%20Substring%20Concatenation%20II/README.md) | | 困难 | 第 443 场周赛 |
35183518
| 3505 | [使 K 个子数组内元素相等的最少操作数](/solution/3500-3599/3505.Minimum%20Operations%20to%20Make%20Elements%20Within%20K%20Subarrays%20Equal/README.md) | | 困难 | 第 443 场周赛 |
3519+
| 3506 | [Find Time Required to Eliminate Bacterial Strains II](/solution/3500-3599/3506.Find%20Time%20Required%20to%20Eliminate%20Bacterial%20Strains%20II/README.md) | | 困难 | 🔒 |
35193520

35203521
## 版权
35213522

‎solution/README_EN.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3514,6 +3514,7 @@ Press <kbd>Control</kbd> + <kbd>F</kbd>(or <kbd>Command</kbd> + <kbd>F</kbd> on
35143514
| 3503 | [Longest Palindrome After Substring Concatenation I](/solution/3500-3599/3503.Longest%20Palindrome%20After%20Substring%20Concatenation%20I/README_EN.md) | | Medium | Weekly Contest 443 |
35153515
| 3504 | [Longest Palindrome After Substring Concatenation II](/solution/3500-3599/3504.Longest%20Palindrome%20After%20Substring%20Concatenation%20II/README_EN.md) | | Hard | Weekly Contest 443 |
35163516
| 3505 | [Minimum Operations to Make Elements Within K Subarrays Equal](/solution/3500-3599/3505.Minimum%20Operations%20to%20Make%20Elements%20Within%20K%20Subarrays%20Equal/README_EN.md) | | Hard | Weekly Contest 443 |
3517+
| 3506 | [Find Time Required to Eliminate Bacterial Strains II](/solution/3500-3599/3506.Find%20Time%20Required%20to%20Eliminate%20Bacterial%20Strains%20II/README_EN.md) | | Hard | 🔒 |
35173518

35183519
## Copyright
35193520

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /