코딩테스트 문제집/Softeer(Lv1): FIN
[Softeer] Lv1: 나무 심기(7353)
cogito30
2025. 2. 9. 07:41
반응형
문제
- 링크: https://softeer.ai/practice/7353
풀이
더보기
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] ground = new int[n];
for (int i = 0; i < n; ++i) {
ground[i] = sc.nextInt();
}
Arrays.sort(ground);
int a = ground[0] * ground[1];
int b = ground[ground.length - 1] * ground[ground.length - 2];
int maxValue = (a > b) ? a : b;
System.out.println(maxValue);
}
}
반응형