Submission #9762

# Submission time Handle Problem Language Result Execution time Memory
9762 2014-09-28T08:46:18 Z silas Uniting (kriii2_U) C++
0 / 4
20 ms 1676 KB
#include <iostream>
#include <queue>
#include <functional>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	vector<int> arr;
	int cost = 0; // 비용의 합의 최솟값
	int num, temp; // num : 부서의 수
	cin >> num;
	for (int i = 0 ; i < num; i++) {
		cin >> temp;
		arr.push_back(temp);
	}
	sort(arr.begin(), arr.end());
	while (arr.size() > 1) {
		cost += arr[0] * arr[arr.size() - 1];
		int tmp = arr[0] + arr[arr.size() - 1];
		arr.erase(arr.begin()); arr.pop_back();
		arr.push_back(tmp);
		sort(arr.begin(), arr.end());
	}
	cout << cost << endl;
	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Partially correct 0 ms 1676 KB Output is partially correct
2 Partially correct 0 ms 1676 KB Output is partially correct
3 Partially correct 0 ms 1676 KB Output is partially correct
4 Partially correct 0 ms 1676 KB Output is partially correct
5 Partially correct 8 ms 1676 KB Output is partially correct
6 Incorrect 20 ms 1676 KB Output isn't correct
7 Halted 0 ms 0 KB -