https://www.acmicpc.net/problem/7568
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int numOfPerson = Integer.parseInt(br.readLine());
StringTokenizer st;
List<BodyFrame> frames = new ArrayList<>();
//입력받아서 리스트에 넣기
for(int i=0; i<numOfPerson; i++){
st = new StringTokenizer(br.readLine());
int height = Integer.parseInt(st.nextToken());
int weight = Integer.parseInt(st.nextToken());
frames.add(new BodyFrame(height, weight));
}
//덩치 크면 덩치 등수++
for(int i=0; i<numOfPerson; i++){
for(int j=0; j<numOfPerson; j++){
if(i == j) continue;
if(frames.get(i).height < frames.get(j).height && frames.get(i).weight < frames.get(j).weight){
frames.get(i).frameRank++;
}
}
}
for(int i=0; i<frames.size(); i++){
System.out.println(frames.get(i).frameRank);
}
}
}
class BodyFrame {
int height;
int weight;
int frameRank = 1;
public BodyFrame(int height, int weight) {
this.height = height;
this.weight = weight;
}
}
'알고리즘 > 백준' 카테고리의 다른 글
백준 1436번 - 영화감독 숌 (Java 8) (0) | 2022.03.01 |
---|---|
백준 1018번 - 체스판 다시 칠하기 (Java 8) (0) | 2022.03.01 |
백준 2231번 - 분해합 (Java 8) (0) | 2022.02.28 |
백준 2798번 - 블랙잭 (Java 8) (0) | 2022.02.28 |
백준 11729번 - 하노이 탑(Java 8) (0) | 2022.02.27 |
댓글