Preparing Coding Test/Baekjoon
[Java/백준/브루트 포스] 7568 - 덩치
weero
2020. 8. 26. 21:51
문제
https://www.acmicpc.net/problem/7568
7568번: 덩치
우리는 사람의 덩치를 키와 몸무게, 이 두 개의 값으로 표현하여 그 등수를 매겨보려고 한다. 어떤 사람의 몸무게가 x kg이고 키가 y cm라면 이 사람의 덩치는 (x,y)로 표시된다. 두 사람 A 와 B의 덩�
www.acmicpc.net
코드
import java.util.Scanner;
public class Main{
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int N = in.nextInt();
int[][] people = new int[N][2];
int[] answer = new int[N];
for(int i=0; i<N; i++) {
people[i][0] = in.nextInt();
people[i][1] = in.nextInt();
}
for(int i=0; i<N; i++) {
int tmp = 0;
for(int j=0; j<N; j++) {
if(i!=j && people[i][0]<people[j][0] && people[i][1]<people[j][1]) {
tmp++;
}
}
answer[i] = tmp+1;
}
for(int i=0; i<N; i++) {
System.out.print(answer[i]);
if(i!=N-1)
System.out.print(" ");
else
System.out.println();
}
}
}