프로그래밍언어/알고리즘

백준 10810 공 넣기_JAVA

새끼개발자 2023. 5. 7. 13:18

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

 

10810번: 공 넣기

도현이는 바구니를 총 N개 가지고 있고, 각각의 바구니에는 1번부터 N번까지 번호가 매겨져 있다. 또, 1번부터 N번까지 번호가 적혀있는 공을 매우 많이 가지고 있다. 가장 처음 바구니에는 공이

www.acmicpc.net

 

 

 

 

 


import java.util.Scanner;

public class Main{
   public static void main(String[] args)  {
	   
	   Scanner sc = new Scanner(System.in);
	   int N = sc.nextInt();
	   int M = sc.nextInt();
	   
	   int[] array = new int[N];

	   for(int i =0 ; i < M ; i++) {
		   
		   int start = sc.nextInt();
		   int end = sc.nextInt();
		   int ballnum = sc.nextInt();
		   
		   
		   for (int j = start  ; j <= end ; j++) {
			   array[j-1] = ballnum;
		   }
   
	   }
	   
	   for(int a : array){
		   	System.out.print(a + " ");
	   }
	   
	    
    }
    
}