比赛 |
test1 |
评测结果 |
AAAAAAAAAA |
题目名称 |
合并果子 |
最终得分 |
100 |
用户昵称 |
Regnig Etalsnart |
运行时间 |
0.043 s |
代码语言 |
C++ |
内存使用 |
0.31 MiB |
提交时间 |
2017-02-28 20:40:38 |
显示代码纯文本
- #include<iostream>
- #include<cstdio>
- #include<queue>
- using namespace std;
- int n;
- priority_queue<int,vector<int>,greater<int> >h;
- int main()
- {
- freopen("fruit.in","r",stdin);freopen("fruit.out","w",stdout);
- int i,x,y,ans=0;
- scanf("%d",&n);
- for(i=1;i<=n;i++)
- {
- scanf("%d",&x);
- h.push(x);
- }
- for(i=1;i<n;i++)
- {
- x=h.top();
- h.pop();
- y=h.top();
- h.pop();
- ans+=x+y;
- h.push(x+y);
- }
- printf("%d",ans);
- return 0;
- fclose(stdin);fclose(stdout);
- }