Notice
Recent Posts
Recent Comments
ยซ   2024/09   ยป
์ผ ์›” ํ™” ์ˆ˜ ๋ชฉ ๊ธˆ ํ† 
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Tags more
Archives
Today
Total
๊ด€๋ฆฌ ๋ฉ”๋‰ด

๐ŸŒฒ์ž๋ผ๋‚˜๋Š”์ฒญ๋…„

Q1026 ๋ณด๋ฌผ(java) ๋ณธ๋ฌธ

์•Œ๊ณ ๋ฆฌ์ฆ˜ ๋ฌธ์ œํ’€์ด

Q1026 ๋ณด๋ฌผ(java)

JihyunLee 2019. 9. 15. 13:06
๋ฐ˜์‘ํ˜•

 

๋„์›€์„ ์–ป์€๊ณณ : https://endorphin0710.tistory.com/73

 

[๋ฐฑ์ค€-1026] ๋ณด๋ฌผ [java code]

https://www.acmicpc.net/problem/1026 [์ž๋ฐ”์ฝ”๋“œ] import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.Scanner; public class S1026 { public static vo..

endorphin0710.tistory.com

 

๋‚ด ์ฝ”๋“œ(java)

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 
public class Q1026{
    public static void main(String args[]){
        Scanner scan = new Scanner(System.in);
        ArrayList<Integer> A = new ArrayList<>();
        ArrayList<Integer> B = new ArrayList<>();
        int N = scan.nextInt();
 
        for(int i=0; i<N; i++){
            A.add(scan.nextInt());
        }
        for(int i=0; i<N; i++){
            B.add(scan.nextInt());
        }
 
        Collections.sort(A);
        Collections.sort(B);
        Collections.reverse(B);
 
        int sum =0;
 
        for(int i=0; i<N; i++){
            sum += A.get(i) * B.get(i);
        }
 
        System.out.println(sum);
        
    }
}
cs
๋ฐ˜์‘ํ˜•