网站首页
编程语言
数据库
系统相关
其他分享
编程问答
2542
2024-06-22
LeetCode 2542. 最大子序列的分数(贪心、小顶堆)
2542.最大子序列的分数思路:先对nums2按降序排列,然后遍历nums2的最小值,同时在区间[0,i]中选中k个最大的nums1即可。然后找出最大的ansclassSolution{public:typedefpair<int,int>PII;longlongmaxScore(vector<int>&nums1,vector<int>&nums2,intk)