当前位置:网站首页>365天挑战LeetCode1000题——Day 049 非递增顺序的最小子序列 贪心
365天挑战LeetCode1000题——Day 049 非递增顺序的最小子序列 贪心
2022-08-04 14:56:00 【ShowM3TheCode】
1403. 非递增顺序的最小子序列

代码实现(自解)
class Solution {
public:
vector<int> minSubsequence(vector<int>& nums) {
sort(nums.begin(), nums.end(), greater<int>());
int sum = accumulate(nums.begin(), nums.end(), 0);
int ans = 0;
int pnum = 0;
while (ans * 2 <= sum) {
ans += nums[pnum];
pnum++;
}
vector<int> sub;
for (int i = 0; i < pnum; i++) {
sub.push_back(nums[i]);
}
return sub;
}
};
边栏推荐
- 【问题解决】QT更新组件出现 “要继续此操作,至少需要一个有效且已启用的储存库”
- FRED应用:毛细管电泳系统
- Oracle database user creation, restart, import and export
- 蓝牙技术|上半年全国新增 130 万台充电桩,蓝牙充电桩将成为市场主流
- leetcode: 259. Smaller sum of three numbers
- [in-depth study of 4 g / 5 g / 6 g project - 50] : URLLC - 16 - the 3 GPP URLLC agreement, specification, technical principle of depth interpretation - 10 - high reliability technology - 1 - low codin
- 1403. Minimum Subsequence in Non-Increasing Order
- leetcode: 253. How many meeting rooms are required at least
- 本周讨论用户体验:Daedalus 的 Nemo 加入 Ambire,探索加密海洋
- 大众点评搜索相关性技术探索与实践
猜你喜欢

leetcode: 255 Verify preorder traversal sequence binary search tree

Phasecraft连下两城,助力英国量子技术商业化加速!

leetcode: 253. How many meeting rooms are required at least

1401 - Web technology 】 【 introduction to graphical Canvas

Cisco-小型网络拓扑(DNS、DHCP、网站服务器、无线路由器)

leetcode: 250. Count subtrees of equal value

QT笔记——Q_INVOKABLE了解

Database recovery

leetcode:215无序数组中找第k大的元素

MySQL优化学习笔记
随机推荐
Bluetooth Technology|In the first half of the year, 1.3 million charging piles were added nationwide, and Bluetooth charging piles will become the mainstream of the market
PTA 6-2 多项式求值
【问题解决】QT更新组件出现 “要继续此操作,至少需要一个有效且已启用的储存库”
16. Learn MySQL Regular Expressions
leetcode:255 验证前序遍历序列二叉搜索树
leetcode: 212. Word Search II
基本介绍PLSQL
Android Sqlite3 basic commands
微软表示将向内部网络安全专家共享数据 为企业提供更安全保护
输入输出流总结
快解析结合友加畅捷U+
【HMS core】【Media】【视频编辑服务】 在线素材无法展示,一直Loading状态或是网络异常
CloudCompare&PCL 点云按网格划分(点云分幅)
Cisco-小型网络拓扑(DNS、DHCP、网站服务器、无线路由器)
AOSP内置APP特许权限白名单
vim common operation commands
Next -20- 使用自定义样式 (custom style)
期货开户之前要谈好最低手续费和交返
B.构造一个简单的数列(贪心)
7 天找个 Go 工作,Gopher 要学的条件语句,循环语句 ,第3篇