[알고리즘] 백준 - 7568 (덩치) / 자바

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = 0; 
		n = sc.nextInt();
		int[][] person = new int[n][n];
		
		for (int i = 0 ; i < n ; i ++) {
			person[i][0] = sc.nextInt();  // 키
			person[i][1] = sc.nextInt();  // 몸무게	
		}
			
		for (int i = 0 ; i < n ; i ++) {  //기준
			int count = 1;
			for (int j = 0 ; j < n ; j++) {   //비교
				if(i==j) {  // 같은 사람은 비교하지 않는다
					continue;
				}
				if ( (person[i][0] < person[j][0] ) && ( person[i][1] < person[j][1] )) { // 자신보다 덩치가 큰 사람이 있으면 카운트를 증가
					count++;
				}
			}
			System.out.print(count + " " );
		}
	}
}

좋은 웹페이지 즐겨찾기