记录编号 |
369167 |
评测结果 |
AAAAAAAAAA |
题目名称 |
[NOIP 2004]合并果子 |
最终得分 |
100 |
用户昵称 |
yzh-- |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
0.040 s |
提交时间 |
2017-02-08 11:40:12 |
内存使用 |
0.31 MiB |
显示代码纯文本
- #include<iostream>
- #include<queue>
- #include<cstdio>
- using namespace std;
- int n;
- priority_queue<int,vector<int>,greater<int> >h;
- void work()
- {
- int i,x,y,ans=0;
- cin>>n;
- for(i=1;i<=n;i++)
- {
- cin>>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);
- }
- cout<<ans<<endl;
- }
- int main()
- {
-
- freopen("fruit.in","r",stdin);
- freopen("fruit.out","w",stdout);
- work();
- return 0;
- }