Skip to content

Commit 6d4c2bc

Browse files
committed
feat: 20260313 check in
1 parent 9e3ab18 commit 6d4c2bc

2 files changed

Lines changed: 44 additions & 3 deletions

File tree

leetcode/5-周赛/第 416 场周赛/3296. 移山所需的最少秒数.md

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# [3296. 移山所需的最少秒数](https://leetcode.cn/problems/minimum-number-of-seconds-to-make-mountain-height-zero/description/)
22

3-
> **作者**弘树
4-
> **日期**2024-09-22
3+
> **日期**2024-09-22、2026-03-13
4+
> **知识点**二分答案
55
66
## 1. 二分答案
77

@@ -32,6 +32,32 @@ $$
3232
- 时间复杂度: $O(nlogU)$
3333
- 空间复杂度: $O(1)$
3434

35+
**Python3**
36+
37+
```python
38+
class Solution:
39+
def minNumberOfSeconds(self, mountainHeight: int, workerTimes: List[int]) -> int:
40+
def check(minute):
41+
height = 0
42+
for workerTime in workerTimes:
43+
h = int(sqrt(minute * 2 / workerTime))
44+
while h * (h + 1) * workerTime > 2 * minute:
45+
h -= 1
46+
height += h
47+
if height >= mountainHeight:
48+
return True
49+
return False
50+
51+
l, r = 1, int(1e17)
52+
while l < r:
53+
mid = l + r >> 1
54+
if check(mid):
55+
r = mid
56+
else:
57+
l = mid + 1
58+
return r
59+
```
60+
3561
**C++**
3662

3763
```C++

leetcode/其他/2826. 将三个组排序.md

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# [2826. 将三个组排序](https://leetcode.cn/problems/sorting-three-groups/description/)
22

3-
> **日期**:2025-05-22
3+
> **日期**:2025-05-22、2026-03-13
44
> **所用时间**:2min
55
66
## 1. 最长递增子序列
@@ -30,4 +30,19 @@ class Solution:
3030
if nums[i] >= nums[j]:
3131
f[i] = max(f[i], f[j] + 1)
3232
return len(nums) - max(f)
33+
```
34+
35+
**Python3**
36+
37+
```python
38+
class Solution:
39+
def minimumOperations(self, nums: List[int]) -> int:
40+
f = []
41+
for x in nums:
42+
i = bisect.bisect_right(f, x)
43+
if i == len(f):
44+
f.append(x)
45+
else:
46+
f[i] = x
47+
return len(nums) - len(f)
3348
```

0 commit comments

Comments
 (0)