作者在 2022-01-24 08:34:42 发布以下内容
void 平均分配箱子数量()
{//缘由https://bbs.bccn.net/redirect.php?tid=508218&goto=lastpost#lastpost
int n = 0, a[100000]{}, x = 0, a1 = 0, a2 = 0;
std::cin >> n;
while (x<n)std::cin >> a[x++]; std::sort(a, a + x);
while (x--) (a1<a2 ? a1 += a[x] : a2 += a[x]);
std::cout << (a1>a2 ? a1 : a2) << "\t" << (a1>a2 ? a2 : a1) << "\n";
}