Submission #9764

#TimeUsernameProblemLanguageResultExecution timeMemory
9764dolpang2Uniting (kriii2_U)C++14
0 / 4
0 ms1244 KiB
#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 timeMemoryGrader output
Fetching results...