首页 > 其他 > 详细

NOIPTG2004合并果子

时间:2019-10-02 23:56:03      阅读:168      评论:0      收藏:0      [点我收藏+]
//堆
#include <bits/stdc++.h> using namespace std; #define fr(i,m,n) for(int i=m;i<=n;i++)int x,y,n,t,ans; priority_queue< int,vector<int>,greater<int> > h; int main() { ios::sync_with_stdio(false); cin >> n; fr(i,1,n){ cin >> t; h.push(t); } fr(i,1,n-1){ x = h.top(); h.pop(); y = h.top(); h.pop(); ans += x + y; h.push(x + y); } cout << ans; return 0; }

 

NOIPTG2004合并果子

原文:https://www.cnblogs.com/phemiku/p/11618501.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!