백준 7568번(Java)

박은지·2025년 2월 4일
0

백준

목록 보기
19/89
post-thumbnail

import java.io.*;
 
public class Main {

	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringBuilder sb = new StringBuilder();
		
		int N = Integer.parseInt(br.readLine());
		
		int[][] arr = new int[N][2];
		
		String[] str; // 키, 몸무게 분해용
		for(int i=0; i<N; i++) {
			str = br.readLine().split(" ");
			arr[i][0] = Integer.parseInt(str[0]);
			arr[i][1] = Integer.parseInt(str[1]);
		}
		
		for(int i=0; i<N; i++) {
			int rank = 1;
			
			for(int j=0; j<N; j++) {
				if(i==j) continue; // 같으면 비교x
				
				// i가 j보다 덩치가 작으면 rank 증가
				if(arr[i][0] < arr[j][0] && arr[i][1] < arr[j][1]) {
					rank++;
				}
			}
			sb.append(rank).append(' ');
		}
		
		System.out.println(sb);
	}
}
profile
백엔드 개발자가 되고싶은 eunzi😊

0개의 댓글