Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
134783 | 梁乃元 | 紧急集合 | C++ | 通过 | 100 | 3 MS | 360 KB | 490 | 2024-03-02 17:39:09 |
# 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 <= n ; 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 ; }