Submission #9550

#TimeUsernameProblemLanguageResultExecution timeMemory
9550silasUniting (kriii2_U)C++98
0 / 4
0 ms1676 KiB
#include <iostream> #include <queue> #include <functional> using namespace std; int main() { priority_queue <int, vector<int>, greater<int> > q; int n; cin >> n; for (int i = 0; i < n; i++){ int tmp; cin >> tmp; q.push(tmp); } int ans = 0; while (q.size() >= 2) { int a, b; a = q.top(); q.pop(); b = q.top(); q.pop(); ans += a * b; q.push(a + b); } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...