로프 무게를 받아 오름차순으로 작은 순서로 정렬한 다음
작은 로프 무게부터 남은 로프의 개수를 곱해서 가능한 최대 중량을 계산하고
최대값을 구해서 출력하면 된다.
이때 작은 로프를 제외하고 남은 로프의 개수로 다시 구한다.
예를 들어 로프 무게가 1,5,10,15가 있다면
가능한 최대 중량의 경우의 수는
import java.util.*;
import java.io.*;
public class _2217 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int[] arr = new int[n];
for(int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(br.readLine());
}
Arrays.sort(arr);
int maxWeight = 0;
// 최대 중량은 가장 무거운 로프 중량 * 로프의 개수
for(int i = 0; i < n; i++) {
maxWeight = Math.max(maxWeight, arr[i] * (n - i));
}
System.out.println(maxWeight);
}
}