답안 #9745

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
9745 2014-09-28T08:37:27 Z dolpang2 Uniting (kriii2_U) C++14
0 / 4
0 ms 1244 KB
#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 -