提交时间:2024-03-02 17:38:43

运行 ID: 134782

# include <bits/stdc++.h> using namespace std ; int a [20005] , b [20005] , t [20005] ; priority_queue <int , vector <int> , greater <int> > q ; int main ( ) { int n , ans = 0 ; cin >> n ; for ( int i = 1 ; i <= 0 ; i ++ ) { int t ; cin >> t ; q . push ( t ) ; } while ( q . size ( ) >= 2 ) { int a = q . top ( ) ; q . pop ( ) ; int b = q . top ( ) ; q . pop ( ) ; ans += a + b ; q . push ( a + b ) ; } cout << ans << endl ; return 0 ; }