NO.10810
풀이코드
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int N = sc.nextInt();
int arr[] = new int[N];
int M = sc.nextInt();
for(int i=0; i<M; i++) {
int I = sc.nextInt();
int J = sc.nextInt();
int K = sc.nextInt();
for(int j=I-1; j<J; j++) { // index 0부터 시작이라 I-1
arr[j] = K;
}
}
for(int k=0; k<arr.length; k++) {
System.out.print(arr[k]+" ");
}
}
}
'JAVA-BAEKJOON > 4단계 1차원 배열' 카테고리의 다른 글
[백준/04-06] 10813 공 바꾸기 (1) | 2024.03.17 |
---|---|
[백준/04-04] 2562 최댓값 (0) | 2024.03.10 |
[백준/04-03] 10818 최소, 최대 (0) | 2024.03.05 |
[백준/04-02] 10871 X보다 작은 수 (0) | 2024.03.01 |
[백준/04-01] 10807 개수 세기 (0) | 2024.03.01 |