Java

[백준7568] - 덩치 JAVA 실버5

Runningturtle 2024. 9. 11. 23:44

 

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

 

 

 

 

package user;
import java.util.*;
 

class Q7568 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		ArrayList<String> li = new ArrayList<>();	
		ArrayList<ArrayList<Integer>> li2 = new ArrayList<>();  // 2차원 어레이리스트
		String rank = "";
		
		String temp = "";
		String [] tempLi ;
		int n= sc.nextInt();  // 개행문자 \n은 남아버린다 그래서 nextLine으로 없애줘야됨
		sc.nextLine();
		
		for (int i=0;i<n;i++)
		{
			temp = sc.nextLine();
			li.add(temp);
			temp = "";
		}
		
		for (int i=0;i<n;i++)
		{
			ArrayList<Integer> li3 = new ArrayList<>();  // 어레이리스트를 초기화하면 다른 언레이리스트도 초기화되서 재선언해서 초기화해야됨걍 
			tempLi= li.get(i).split(" ");
			li3.add(Integer.parseInt(tempLi[0]));
			li3.add(Integer.parseInt(tempLi[1]));
			li2.add(li3);	 
		}
		  // 이차원 어레이리스트는 get 두번
		int cnt = 0;
		  for(int i = 0;i<n;i++) {
			  for(int j =0;j<n;j++) {
				  if(li2.get(i).get(0) < li2.get(j).get(0) && li2.get(i).get(1) < li2.get(j).get(1))
					  cnt++;
			  }
			 int a = cnt+1;
			 rank = rank + Integer.toString(a) + " ";
			 cnt = 0;
		  }
		  
		 System.out.println(rank);
	 
		//여러줄 주석 컨트롤+쉬프트+/   해제는 \ 
	}

}

 

 

 

 

파이썬으로 풀다가 자바로 푸니 새롭고 재밌다.

 

알아가야 할것이 산더미처럼 보인다.