148マージ果物をAcWing

書式#include <iostreamの> 
の#include <アルゴリズム> 
書式#include <キュー>
 使用して 名前空間をSTD。
int型のmain(){
     int型、nは 
    scanf関数(" %のD "、&N)
    PRIORITY_QUEUE < int型、ベクトル< int型 >、大きい< int型 >> ヒープ。
    一方、(N - ){
         int型のX; 
        scanf関数(" %のD "、&x)は、
        heap.push(X)。
    } 
    INT RES = 0 一方、(heap.size()> 1 ){
         int型 A = heap.top()。
        heap.pop(); 
        INT B = heap.top()。
        heap.pop(); 
        RES + = A + B。
        heap.push( +のB)。
    } 
    のprintf(" %dの\ n " 、RES)。
    リターン 0 ; 
}

 

 

おすすめ

転載: www.cnblogs.com/QingyuYYYYY/p/11909465.html