알고리즘/백준
백준 7568 덩치 자바
reumiii
2020. 1. 21. 22:26
키와 몸무게를 비교하여 더 작으면 등수를 1씩 증가하도록 함
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();// 전체 사람의 수 N
int x[] = new int[n];// 몸무게
int y[] = new int[n];// 키
int result[] = new int[n];// 등수
for (int i = 0; i < n; i++) {
x[i] = sc.nextInt();
y[i] = sc.nextInt();
}
for (int i = 0; i < n; i++) {
result[i] = 1;
for (int j = 0; j < n; j++) {
if (i != j) {
if (x[i] < x[j] && y[i] < y[j]) {// 키와 몸무게 모두 더 작으면
result[i]++;// 등수 뒤로 밀려남
}
}
}
System.out.println(result[i]);// 결과 등수 출력
}
}
}