[백준] 2217. 로프(실버4)

백준(실버4) - 2217. 로프(실버4)



풀이

import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		
		Integer[] rope = new Integer[n];
		
		for(int i=0; i<n; i++) {
			rope[i] = sc.nextInt();
		}
		Arrays.sort(rope,Collections.reverseOrder());
		
		int max = rope[0];
		
		for(int i=1; i<n; i++) {
			rope[i] *= (i+1);
			if(max <rope[i]) max = rope[i];
		}
		System.out.println(max);
	}
}

좋은 웹페이지 즐겨찾기