-
백준 : greedy - 로프 - 2217번(java)Tech-blog/Algorithm 2023. 2. 19. 18:43
import java.util.Arrays; import java.util.Scanner; public class Rope { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] ropes = new int[N]; for (int i = 0; i < N; i++) ropes[i] = sc.nextInt(); Arrays.sort(ropes); long max = 0; for (int i = N -1;i >= 0; i--){ ropes[i] = ropes[i] * (N - i); if (max < ropes[i]) max = ropes[i]; } System.out.println(max); } }
'Tech-blog > Algorithm' 카테고리의 다른 글
백준 : greedy - 30 - 10610번(java) (0) 2023.02.21 백준 : greedy - 기타줄 - 1049번 (java) (0) 2023.02.20 백준 : 신입 사원 - 1946 (java) (0) 2023.02.16 백준 : 최고의 피자 - 5545번(java) (0) 2023.02.16 백준 : greedy - 13305번 - 주유소(java) (0) 2023.02.14