본문 바로가기
백준

백준 브루트포스 - 7568번 : 덩치

by 맴썰 2022. 2. 6.

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

 

7568번: 덩치

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

www.acmicpc.net


import java.util.*;
public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        body[] ps = new body[n];
        int[] sum = new int[n];
        Arrays.fill(sum,1);
        for(int i=0; i<n; i++){
            int w = sc.nextInt();
            int h = sc.nextInt();
            ps[i] = new body(h,w);
        }
        for(int i=0; i<n; i++){
            for(int j=n-1; j>=0; j--){
                if(ps[i].weight<ps[j].weight&&ps[i].height<ps[j].height){
                   sum[i]++;
                }
            }
        }
        for(int i=0; i<n; i++){
            System.out.print(sum[i]);
            if(i!=n-1)System.out.print(" ");
        }
    }
}
class body{
    int height;
    int weight;
    public body(int h, int w){
        this.weight = w;
        this.height = h;
    }
}