백준 문제풀기/그리디알고리즘
로프_백준2217
psys
2020. 6. 2. 16:38
728x90
문제
https://www.acmicpc.net/problem/2217
import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
int[] num = new int[n];
int max = Integer.MIN_VALUE;
for (int i = 0; i < num.length; i++) {
num[i]=s.nextInt();
}
Arrays.sort(num);
for (int i = 0; i < num.length; i++) {
max = Math.max(max, num[i]*(n-i));
}
System.out.println(max);
}
}