这题很坑,要用long long
#include <cstdio>
#include <set>
using namespace std;
int main(){
int t, n;
long long temp, sum;
multiset<long long> mst;
multiset<long long>::iterator it;
scanf("%d", &t);
while(t--){
scanf("%d", &n);
while(n--){
scanf("%lld", &temp);
mst.insert(temp);
}
sum = 0;
while(mst.size() > 1){
it = mst.begin();
temp = *it;
mst.erase(it);
it = mst.begin();
temp += *it;
mst.erase(it);
sum += temp;
mst.insert(temp);
}
mst.clear();
printf("%lld\n", sum);
}
return 0;
}
800940 | 长木 | 懒省事的小明 | Accepted | 124 | 572 | C/C++ | 04-07 17:47:52 |