比赛 |
板子大赛 |
评测结果 |
AAAAAAAAAA |
题目名称 |
合并果子 |
最终得分 |
100 |
用户昵称 |
李金泽 |
运行时间 |
0.065 s |
代码语言 |
C++ |
内存使用 |
3.09 MiB |
提交时间 |
2025-01-22 14:43:18 |
显示代码纯文本
#include<cstdio>
#include<queue>
#define N 10005
#define ll long long
using namespace std;
int n;ll x,ans;
priority_queue<int,vector<int>,greater<int> >q;
int main()
{
freopen("fruit.in","r",stdin);freopen("fruit.out","w",stdout);
scanf("%d",&n);
while(n--)scanf("%lld",&x),q.push(x);
while(q.size()>1)
{
x=q.top(),q.pop();x+=q.top(),q.pop();
q.push(x);ans+=x;
}
printf("%lld",ans);
return 0;
}