내림차순 , 오름차순 이용하여 문제풀이
package silver4;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Scanner;
public class 보물1026 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
Integer A[] = new Integer[N];
Integer B[] = new Integer[N];
for(int i =0; i<N; i++) {
A[i] = sc.nextInt();
} // a에 넣어주고
for(int i =0; i<N; i++) {
B[i] = sc.nextInt();
}
Arrays.sort(A,Collections.reverseOrder()); // 오름차순
Arrays.sort(B); // 내림차순
int result = 0 ;
int ans = Integer.MAX_VALUE;
int min = 0;
for(int i = 0; i<N; i++) {
result += A[i] * B[i];
min = Math.min(result,ans);
}
System.out.println(min);
}
}