核心代码
while (q.size() > 1) {
x = q.top();
q.pop();
x += q.top();
q.pop();
q.push(x);
sum += x;
}while (q.size() > 1) {
x = q.top(while (q.size() > 1) {
x = q.top();
q.pop();
x += q.top();
q.pop();
q.push(x);
sum += x;
}while (q.size() > 1) {
x = q.top(