标签:sep page transport span tran pack contain second 提交
4
6
2 3 4 4 5 7
5
5 15 40 30 10
10
3 1 5 4 8 2 6 1 1 2
9
3 2 1 6 5 2 6 4 3
63
205
100
98
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
int t, n;
int main(){
scanf("%d", &t);
while(t -- ){
scanf("%d", &n);
priority_queue<int ,vector<int>, greater<int>> q;
while (n -- ){
int x;
scanf("%d", &x);
q.push(x);
}
long long res = 0;
while (q.size() > 1){
int x = q.top(); q.pop();
int y = q.top(); q.pop();
res += x + y;
q.push(x + y);
}
printf("%lld\n", res);
}
return 0;
}
标签:sep page transport span tran pack contain second 提交
原文地址:https://www.cnblogs.com/Iamcookieandyou/p/13656615.html