# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
9550 | silas | Uniting (kriii2_U) | C++98 | 0 ms | 1676 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |