设为首页 加入收藏

TOP

poj3253(优先队列)
2015-07-20 17:18:54 来源: 作者: 【 】 浏览:2
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

评论

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

·MySQL 基础入门视频 (2025-12-26 23:20:22)
·小白入门:MySQL超详 (2025-12-26 23:20:19)
·关于 MySQL 数据库学 (2025-12-26 23:20:16)
·SOLVED: Ubuntu 24.0 (2025-12-26 22:51:53)
·Linux 常用命令最全 (2025-12-26 22:51:50)