Skip to content

Commit

Permalink
Create Readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
wisdompeak authored Jan 21, 2023
1 parent e0a88a7 commit 1e3098e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Priority_Queue/2542.Maximum-Subsequence-Score/Readme.md
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即可实现。

0 comments on commit 1e3098e

Please sign in to comment.