본문 바로가기
백준 알고리즘/그리디 알고리즘

로프 C++

by paysmile 2019. 10. 10.

#include <iostream>
#include <algorithm>

using namespace std;
const int MAX = 100001;
int n;
int lope[MAX];

int main(void) {
	cin >> n;
	int answer = -1;

	for (int i = 0; i < n; i++)
		cin >> lope[i];

	sort(lope, lope + n);
	
	for (int j = 0; j < n; j++) {
		answer = max(answer, lope[j]*(n-j));
	}
	cout << answer << endl;
	return 0;
}

'백준 알고리즘 > 그리디 알고리즘' 카테고리의 다른 글

백준 1049번 C++  (0) 2019.10.11
대회 or 인턴 C++  (0) 2019.10.11
백준 1120번 C++  (0) 2019.08.28
백준 10610번 C++  (0) 2019.02.18
백준 1931번 C++  (0) 2019.02.18