文章
34
粉丝
316
获赞
10
访问
23.0k
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
priority_queue<int ,vector<int>,greater<int>>data;
int t;
for (int i = 0; i < n; i++)
{
cin >> t;
data.push(t);
}
int result=0;
while (data.size() != 1) {
int x1, x2;
x1 = data.top();
data.pop();
x2 = data.top();
data.pop();
data.push(x1 + x2);
result = result + x1 + x2;
}
&nbs...
登录后发布评论
暂无评论,来抢沙发