# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
9764 | dolpang2 | Uniting (kriii2_U) | C++14 | 0 ms | 1244 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 <algorithm>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <vector>
const int kModulo = 1000000007;
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 % kModulo);
printf("0");
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |