최솟값 만들기 Level 2
import java.util.Arrays;
class TryHelloWorld
{
public int getMinSum(int []A, int []B)
{
int answer = 0;
Arrays.sort(A); //
Arrays.sort(B);
for(int i=0; i <A.length; i++) {
answer += A[i] * B[A.length-i-1];
}
return answer;
}
public static void main(String[] args)
{
TryHelloWorld test = new TryHelloWorld();
int []A = {1,2};
int []B = {3,4};
System.out.println(test.getMinSum(A,B));
}
}
'프로그래밍 > 알고리즘(자바)' 카테고리의 다른 글
2016년 Level 2 #달력(요일) 알고리즘 (0) | 2018.05.07 |
---|---|
콜라츠 추측 Level 2 #삼항연산자 (0) | 2018.05.07 |
소수 찾기 Level 2 #Math.sqrt #소수 (0) | 2018.05.06 |
삼각형출력하기 Level 1 (0) | 2018.05.06 |
수박수박수박수박수박수? Level 1 #join #replace #StringBuffer #append #String '+=' 연산 (0) | 2018.05.06 |