当前位置:网站首页>1403. Minimum Subsequence in Non-Increasing Order
1403. Minimum Subsequence in Non-Increasing Order
2022-08-04 14:36:00 【anieoo】
Original title link: 1403. Minimum subsequence in non-increasing order
solution:
class Solution {public:vector minSubsequence(vector& nums) {sort(nums.begin(), nums.end());int sum = 0;for(auto &x : nums) sum += x;vector res; //return valueint s = 0,j = nums.size() - 1;while(j >= 0 && s <= sum / 2) {res.push_back(nums[j]);s += nums[j--];}return res;}};
边栏推荐
猜你喜欢
随机推荐
Technology sharing | Description of the electronic fence function in the integrated dispatching system
阿里老鸟终于把测试用例怎么写说的明明白白了,小鸟必看
Makefile syntax and usage notes
快解析结合千方百剂
xampp安装包含的组件有(php,perl,apche,mysql)
没有Project Facets的解决方法
砺夏行动|九州云章津楠:开源不是少数人的运动,大众化才是源泉
Crawler - basic use of selenium, no interface browser, other uses of selenium, cookies of selenium, crawler cases
爬虫——动作链、xpath、打码平台使用
如何才能有效、高效阅读?猿辅导建议“因材因时施教”
谷歌插件.crx文件下载后被自动删除的解决方法
文盘Rust -- 配置文件解析
第十六章 源代码文件 REST API 教程(一)
世间几乎所有已知蛋白质结构,都被DeepMind开源了
Almost all known protein structures in the world are open sourced by DeepMind
[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
字符串类的设计与实现_C语言字符串编程题
小 P 周刊 Vol.13
[LeetCode] 38. Appearance sequence
C# winforms 输入颜色转换颜色名