Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
134368 | 曾煦翔 | 紧急集合 | C++ | 通过 | 100 | 3 MS | 460 KB | 438 | 2024-03-02 15:44:41 |
#include <bits/stdc++.h> #define int long long using namespace std; int x , tmp1 , tmp2 , sum , cnt; priority_queue<int,vector<int>,greater<int> > q; signed main() { int n; cin >> n; for(int i = 1; i <= n; i++) { cin >> x; q.push(x); } while(q.size()>1) { tmp1 = q.top(); q.pop(); tmp2 = q.top(); q.pop(); sum = tmp1 + tmp2; q.push(sum); cnt += sum; } cout << cnt << endl; return 0; }