본문 바로가기
짱구 굴리기 (Q) -

[백준 7568] 덩치

by skwzz 2019. 4. 4.

출처 : https://www.acmicpc.net/problem/7568

브루트 포스 문제입니다

브루트 포스란? (위키백과)

무차별 대입(brute force)은 특정한 암호를 풀기 위해 가능한 모든 값을 대입하는 것을 의미한다.

라 설명이 되있습니다. (무슨 뒤에 공격도 붙어있는데 빼버림) 

일단 입력을 받고 나머지에 대해서 다 돌면서 체크해주시면 되겠습니다.

 

public class Q7568 {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st;
		int num = Integer.parseInt(br.readLine());
		Student[] arr = new Student[num];
		
		for(int i=0; i<num; i++	) {
			st = new StringTokenizer(br.readLine());
			int weight = Integer.parseInt(st.nextToken());
			int height = Integer.parseInt(st.nextToken());
			
			arr[i] = new Student(weight, height);
		}
		
		for(int i=0; i<arr.length; i++	) {
			for(int j=0; j<arr.length; j++) {
				if(i==j) {
					continue;
				}
				if(arr[i].weight > arr[j].weight && arr[i].height > arr[j].height) {
					arr[j].rank++;
				}
			}
		}
		for(int i=0; i<arr.length; i++) {
			System.out.print(arr[i].rank+" ");
		}
	}
}

class Student{
	int weight;
	int height;
	int rank;
	
	public Student(int weight, int height) {
		this.weight = weight;
		this.height = height;
		this.rank = 1;
	}
}

'짱구 굴리기 (Q) - ' 카테고리의 다른 글

[백준 2193] 이친수  (0) 2019.04.05
[백준 1932] 정수 삼각형  (0) 2019.04.04
[백준 1003] 피보나치 함수  (0) 2019.04.03
[백준 10826] 피보나치 수 4  (0) 2019.04.03
[백준 2747] 피보나치 수  (0) 2019.04.03