https://www.acmicpc.net/problem/7568
7568번: 덩치
우리는 사람의 덩치를 키와 몸무게, 이 두 개의 값으로 표현하여 그 등수를 매겨보려고 한다. 어떤 사람의 몸무게가 x kg이고 키가 y cm라면 이 사람의 덩치는 (x, y)로 표시된다. 두 사람 A 와 B의 덩
www.acmicpc.net
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
body[] ps = new body[n];
int[] sum = new int[n];
Arrays.fill(sum,1);
for(int i=0; i<n; i++){
int w = sc.nextInt();
int h = sc.nextInt();
ps[i] = new body(h,w);
}
for(int i=0; i<n; i++){
for(int j=n-1; j>=0; j--){
if(ps[i].weight<ps[j].weight&&ps[i].height<ps[j].height){
sum[i]++;
}
}
}
for(int i=0; i<n; i++){
System.out.print(sum[i]);
if(i!=n-1)System.out.print(" ");
}
}
}
class body{
int height;
int weight;
public body(int h, int w){
this.weight = w;
this.height = h;
}
}
'백준' 카테고리의 다른 글
백준 브루트포스 - 1436번 :영화감독 숌 (0) | 2022.02.08 |
---|---|
백준 브루트포스 - 1018번 : 체스판 다시 칠하기 (0) | 2022.02.08 |
백준 프루트포스 - 2231번 : 분해합 (0) | 2022.02.06 |
백준 프루트포스 - 2798번: 블랙잭 (0) | 2022.02.06 |
백준 java 기본 Form (0) | 2022.01.24 |