공넣기
문제
입력
출력 및 예제
내 풀이
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N,M;
StringTokenizer st = new StringTokenizer(br.readLine());
N = Integer.parseInt(st.nextToken());
M = Integer.parseInt(st.nextToken());
int[] arr = new int[N];
for(int q = 1; q <= M; q++)
{
StringTokenizer st1 = new StringTokenizer(br.readLine());
int i = Integer.parseInt(st1.nextToken());
int j = Integer.parseInt(st1.nextToken());
int k = Integer.parseInt(st1.nextToken());
for(int b = i; b <= j; b++)
{
arr[b-1] = k;
}
}
for(int n = 0; n < N; n++)
System.out.printf("%d ",arr[n]);
}
}