| 比赛 | 板子大赛 | 评测结果 | AAAAAAAAAA |
|---|---|---|---|
| 题目名称 | 合并果子 | 最终得分 | 100 |
| 用户昵称 | 李奇文 | 运行时间 | 0.086 s |
| 代码语言 | C++ | 内存使用 | 3.35 MiB |
| 提交时间 | 2025-01-22 11:44:45 | ||
#include<bits/stdc++.h>
using namespace std;
int n,x,ans;
priority_queue <int,vector<int>,greater<int> >q;
int main(){
freopen("fruit.in","r",stdin);
freopen("fruit.out","w",stdout);
cin>>n;
for(int i=1;i<=n;i++){
cin>>x;
q.push(x);
}
while(q.size()>1){
int a=q.top();
q.pop();
int b=q.top();
q.pop();
ans+=a+b;
q.push(a+b);
}
cout<<ans<<endl;
return 0;
}