반응형
Notice
Recent Posts
Recent Comments
Link
불로구
백준 알고리즘 - 7568 덩치 (자바)JAVA 본문
반응형
import java.util.Scanner;
class People{
int kg;
int height;
int rank = 1;
public People(int kg, int height) {
this.kg = kg;
this.height = height;
}
}
public class Main {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int n = s.nextInt();
People[] p = new People[n];
for(int i=0; i<p.length; i++) {
p[i] = new People(s.nextInt(),s.nextInt());
}
for(int i=0; i<p.length; i++) {
for(int j=0; j<p.length; j++) {
if(p[i].kg < p[j].kg && p[i].height < p[j].height ) {
p[i].rank += 1;
}
}
}
for(int i=0; i<p.length; i++) {
System.out.print(p[i].rank + " ");
}
}
}
반응형
'프로그래밍 > 알고리즘' 카테고리의 다른 글
[ 자바 알고리즘/자료구조] - 자바 난수배열 && 배열 역순 정렬 (0) | 2021.02.07 |
---|---|
[ 자바 알고리즘/자료구조] - 자바 배열 복사 && 배열의 최대값 (0) | 2021.02.07 |
[ 자바 알고리즘/자료구조] - 반복(1부터 n까지 합) && i++과 ++i (0) | 2021.02.07 |
알고리즘 - 퀵 정렬 (0) | 2020.06.15 |
알고리즘 - 최대공약수(GCD) & 최소공배수(LCM) (유클리드 호제) (0) | 2020.06.15 |
Comments