#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <vector>
int main() {
long long N = 0;
scanf("%lld", &N);
std::deque<long long> bundle_of_number;
for (long long i = 0; i < N; ++i) {
long long number = 0;
scanf("%lld", &number);
bundle_of_number.push_back(number);
}
std::sort(bundle_of_number.begin(), bundle_of_number.end());
long long result = 0;
for (;;) {
if (bundle_of_number.size() == 1) {
break;
}
long long ret = bundle_of_number.at(0) * bundle_of_number.at(1);
bundle_of_number.push_back(ret);
result += ret;
bundle_of_number.pop_front();
bundle_of_number.pop_front();
std::sort(bundle_of_number.begin(), bundle_of_number.end());
}
printf("%lld\n", result);
printf("0");
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
1244 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |