# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
9764 | dolpang2 | Uniting (kriii2_U) | C++14 | 0 ms | 1244 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |