자바 백준 7568번 덩치
키와 몸무게를 비교해 둘다 큰사람이 있으면 그 사람의 순위를 1씩 더해준다.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Scanner; | |
public class Main { | |
public static void main(String args[]) { | |
Scanner sc = new Scanner(System.in); | |
int num = sc.nextInt(); | |
int spell[][] = new int[num][2]; //몸무게, 키 | |
int rank[] =new int[num]; //순위 | |
for(int i=0;i<num;i++) { | |
rank[i] = 1; | |
spell[i][0] = sc.nextInt(); //몸무게 | |
spell[i][1] = sc.nextInt(); //키 | |
} | |
for(int i=0; i<num;i++) { | |
for(int j=0; j<num;j++) { | |
if(spell[i][0]>spell[j][0] && spell[i][1]>spell[j][1]) { | |
rank[j]++; | |
} | |
} | |
} | |
for(int i=0; i<num;i++) { | |
System.out.print(rank[i]+" "); | |
} | |
} | |
} |
'백준 알고리즘 > JAVA' 카테고리의 다른 글
자바 백준 1764번 듣보잡 (1) | 2018.09.02 |
---|---|
자바 백준 5585번 거스름돈 (0) | 2018.09.02 |
자바 백준 1065번 한수 (0) | 2018.08.23 |
자바 백준 2231번 분해합 (0) | 2018.08.23 |
자바 백준 2309번 일곱 난쟁이 (0) | 2018.08.16 |