Study/Problem Solving

[BOJ 7568] 덩치

monitor 2023. 8. 20. 15:39

단순 구현 문제였다.

import java.util.*;
import java.io.*;
public class BOJ_7568 {
    static class Data {
        int weight;
        int height;
        public Data(int x, int y){
            this.weight = x;
            this.height = y;
        }
    }
    public static void main(String[] args) throws Exception{
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer tk = new StringTokenizer(in.readLine()," ");
        int N = Integer.parseInt(tk.nextToken());
        Stack<Data> st = new Stack<>();
        List<Data> list = new ArrayList<>();
        for(int i = 0; i < N; i++){
            tk = new StringTokenizer(in.readLine()," ");
            list.add(new Data(Integer.parseInt(tk.nextToken()),Integer.parseInt(tk.nextToken())));
        }
        int ans = 1;
        for(int j = 0; j < N; j++) {
            for (int i = 0; i < N; i++) {
                if(i == j){
                    continue;
                }
                if ((list.get(j).height < list.get(i).height && list.get(j).weight < list.get(i).weight)) {
                    ans++;
                }
            }
            System.out.print(ans + " ");
            ans = 1;
        }
    }
}
 

7568번: 덩치

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

www.acmicpc.net