首页 > 试题广场 >

第二题

[编程题]第二题
  • 热度指数:9723 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 32M,其他语言64M
  • 算法知识视频讲解
一个数组中有若干正整数,将此数组划分为两个子数组,使得两个子数组各元素之和a,b的差最小,对于非法输入应该输出ERROR。

输入描述:
数组中的元素


输出描述:
降序输出两个子数组的元素和
示例1

输入

10 20 30 10 10
10 20 abc 10 10

输出

40 40
ERROR
头像 BrianWu
发表于 2021-07-07 01:55:06
/*描述一个数组中有若干正整数,将此数组划分为两个子数组,使得两个子数组各元素之和a,b的差最小,对于非法输入应该输出ERROR。输入描述:数组中的元素输出描述:降序输出两个子数组的元素和 Main idea:设两个子数组的元素和分别为 sum1, sum2,数组的元素和为sum,则:sum=sum 展开全文
头像 程昱同学
发表于 2023-01-27 21:00:22
#include <cctype> #include <iostream> #include <sstream> #include <vector> #include <algorithm> using namespace std; vec 展开全文
头像 Ooops!
发表于 2024-05-11 11:00:58
#include <iostream> #include <sstream> #include <vector> #include <cmath> using namespace std;int sum=0,cnt=0;int mini=0x3f3f3 展开全文

问题信息

上传者:小小
难度:
18条回答 6267浏览

热门推荐

通过挑战的用户

查看代码
第二题