当前位置:网站首页>1403. 非递增顺序的最小子序列
1403. 非递增顺序的最小子序列
2022-08-04 14:29:00 【anieoo】
原题链接:1403. 非递增顺序的最小子序列
solution:
class Solution {
public:
vector<int> minSubsequence(vector<int>& nums) {
sort(nums.begin(), nums.end());
int sum = 0;
for(auto &x : nums) sum += x;
vector<int> res; //返回值
int s = 0,j = nums.size() - 1;
while(j >= 0 && s <= sum / 2) {
res.push_back(nums[j]);
s += nums[j--];
}
return res;
}
};
边栏推荐
- 【剑指offer33】二叉搜索树的后序遍历序列
- token 过期后,如何自动续期?
- Theory 1: Deep Learning - Detailed Explanation of the LetNet Model
- 用于X射线聚焦的复合折射透镜
- [Problem solving] QT update component appears "To continue this operation, at least one valid and enabled repository is required"
- CCF GLCC officially opened | Kyushu Cloud open source experts bring generous bonuses to help universities promote open source
- 阴影初始化【5】
- Database recovery
- 四平方和,激光炸弹
- Almost all known protein structures in the world are open sourced by DeepMind
猜你喜欢
快解析结合千方百剂
Win11勒索软件防护怎么打开?Win11安全中心勒索软件防护如何设置
MySQL性能指标TPS\QPS\IOPS如何压测?
【硬件架构的艺术】学习笔记(1)亚稳态的世界
Analysis and application of portrait segmentation technology
Crawler - basic use of selenium, no interface browser, other uses of selenium, cookies of selenium, crawler cases
中大型商业银行堡垒机升级改造就用行云管家!必看!
自监督学习未来是掩码自编码器?KAIST最新《自监督学习掩码自编码器》研究进展
CCF GLCC正式开营|九州云开源专家携丰厚奖金,助力高校开源推广
电子行业MES管理系统有哪些特殊功能
随机推荐
Find My技术|防止你的宠物跑丢,苹果Find My技术可以帮到你
MPLS实验
Crawler - basic use of selenium, no interface browser, other uses of selenium, cookies of selenium, crawler cases
[LeetCode] 38. Appearance sequence
F.金玉其外矩阵(构造)
开发者独立搭建一个跨模态搜索应用有多难?
两款移相振荡器的对比
九州云出席领航者线上论坛,共话5G MEC边缘计算现状、挑战和未来
MPLS experiment
并发程序的隐藏杀手——假共享(False Sharing)
metaRTC5.0新版本支持mbedtls(PolarSSL)
Keycloak 6.0.0 正式发布,身份和访问管理系统
G. Mountaineering Squad (violence & dfs)
技术分享| 小程序实现音视频通话
How to write SQL statements: the usage of Update, Case, and Select together
异步编程概览
Kyushu Cloud attended the Navigator Online Forum to discuss the current status, challenges and future of 5G MEC edge computing
FRED应用:毛细管电泳系统
zabbix自定义图形
第六届未来网络发展大会,即将开幕!