设为首页 加入收藏

TOP

poj3253(优先队列)
2015-07-20 17:18:54 来源: 作者: 【 】 浏览:3
Tags:poj3253 优先 队列
#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        using namespace std; int N,R; int x[50100]; int main() { #ifdef xxz freopen("in.txt","r",stdin); #endif // xxz ios::sync_with_stdio(false); cin.tie(0); while(cin>>N) { priority_queue
       
        ,greater
        
          > P; for(int i = 0; i < N; i++) { cin>>x[i]; P.push(x[i]); } long long ans = 0; while(P.size() > 1) { int L1 = P.top();P.pop(); int L2 = P.top();P.pop(); ans += L1+L2; P.push(L1+L2); } cout<
         
          
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Leopard Jdbc:简化Spring Jdbc使用 下一篇spring2.5整合ibatis

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容:

·有没有哪些高效的c++ (2025-12-27 08:20:57)
·Socket 编程时 Accep (2025-12-27 08:20:54)
·计算机网络知识点总 (2025-12-27 08:20:52)
·一篇说人话的文章, (2025-12-27 07:50:09)
·Python Web框架哪家 (2025-12-27 07:50:06)