forked from wisdompeak/LeetCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e0a88a7
commit 1e3098e
Showing
1 changed file
with
7 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
### 2542.Maximum-Subsequence-Score | ||
|
||
此题和`1383.Maximum Performance of a Team`一模一样。 | ||
|
||
对于此类题目,我们无法同时遍历两个变量。必然是遍历一个变量,然后找另一个变量的最优值。 | ||
|
||
我们观察第二个因子`min(...)`有一个特性,就是随着数量的增多,其值是单调的递减。于是我们想到,将nums按照降序排列,依次考察它的前缀,就可以依次得到所有可能的min值。如果固定了一个团队中的最小值x,那么这个团队里的最大和是多少?显然是将所有大于等于x的成员里挑最大的k个相加即可,一个PQ即可实现。 |