ALGORITHM/BOJ

[백준] 7568 덩치

0298 2022. 2. 2. 22:51

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

 

7568번: 덩치

우리는 사람의 덩치를 키와 몸무게, 이 두 개의 값으로 표현하여 그 등수를 매겨보려고 한다. 어떤 사람의 몸무게가 x kg이고 키가 y cm라면 이 사람의 덩치는 (x, y)로 표시된다. 두 사람 A 와 B의 덩

www.acmicpc.net

2022-02-02


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
33
34
35
36
37
38
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.StringTokenizer;
 
public class Main {
    public static int N;
    public static int[][] arr;
 
    public static void main(String[] args) throws IOException {
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(bf.readLine().trim());
 
        N = Integer.parseInt(st.nextToken());
        arr = new int[N][2];
 
        for(int i = 0; i < N; i++) {
            st = new StringTokenizer(bf.readLine());
            int x = Integer.parseInt(st.nextToken());
            int y = Integer.parseInt(st.nextToken());
            arr[i][0= x;
            arr[i][1= y;
        }
 
        StringBuilder sb = new StringBuilder();
        for(int i = 0; i < N; i++) {
            int cnt = 1;
            for(int j = 0; j < N; j++) {
                if(i == j) continue;
                if(arr[i][1< arr[j][1&& arr[i][0< arr[j][0]) cnt++;
            }
            sb.append(cnt).append(" ");
        }
        System.out.println(sb.toString());
    }
}
cs

#문제풀이

 

브루트포스로 몸무게 키 모두 큰 갯수 카운팅