보물1026

LJM·2023년 1월 27일
0

백준풀기

목록 보기
58/259

https://www.acmicpc.net/problem/1026

import java.io.*;
import java.util.*;

public class Main
{
    static BufferedReader br;

    static int N;

    static Integer[] A;
    static Integer[] B;

    public static void main(String[] args) throws IOException
    {
        inputProcess();

        Arrays.sort(A);
        Arrays.sort(B, Comparator.reverseOrder());

        int sum = 0;
        for(int i = 0; i < N; ++i)
        {
            sum += A[i] * B[i];
        }

        System.out.println(sum);
    }

    public static void inputProcess() throws IOException
    {
        br = new BufferedReader(new InputStreamReader(System.in));

        N = Integer.parseInt(br.readLine());

        A = new Integer[N];
        B = new Integer[N];

        String[] input;
        input = br.readLine().split(" ");
        for(int i = 0; i < N; ++i)
        {
            A[i] = Integer.parseInt(input[i]);
        }

        input = br.readLine().split(" ");
        for(int i = 0; i < N; ++i)
        {
            B[i] = Integer.parseInt(input[i]);
        }
    }


}
profile
게임개발자 백엔드개발자

0개의 댓글