1 solutions
-
0
#include <bits/stdc++.h> using namespace std;
const int N = 10005;
priority_queue<int, vector, greater > q; int n, ans;
int main() { cin >> n; int x; for(int i = 1; i <= n; i++) cin >> x, q.push(x);
while(q.size() >= 2) { int a = q.top(); q.pop(); int b = q.top(); q.pop(); int sum = a + b; q.push(sum); ans += sum; } cout << ans; return 0;
}
- 1
Information
- ID
- 90
- Time
- 800ms
- Memory
- 125MiB
- Difficulty
- 3
- Tags
- # Submissions
- 49
- Accepted
- 29
- Uploaded By