| 比赛 | 贪心题目练习 | 评测结果 | AAAAAAAAAA |
|---|---|---|---|
| 题目名称 | 合并果子 | 最终得分 | 100 |
| 用户昵称 | 长安惊龙灵松 | 运行时间 | 0.066 s |
| 代码语言 | C++ | 内存使用 | 3.63 MiB |
| 提交时间 | 2025-03-22 10:07:17 | ||
#include<bits/stdc++.h>
using namespace std;
int n,a[10005],x,y,ans;
priority_queue<int>q;
int main()
{
freopen("fruit.in","r",stdin);
freopen("fruit.out","w",stdout);
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
scanf("%d",&a[i]);
q.push(-a[i]);
}
while(q.size()>1)
{
x=q.top(),q.pop();
y=q.top(),q.pop();
q.push(x+y);
ans+=x+y;
}
printf("%d",-ans);
return 0;
}