[백준/Java] 10810 : 공 넣기

SEOP·2023년 6월 11일
0
post-custom-banner

import java.io.*;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));

        String[] STR =  br.readLine().split(" ");
        int N = Integer.parseInt(STR[0]);
        int M = Integer.parseInt(STR[1]);

        int[] intArray = new int[N];
        for(int j = 0 ; j < N ; j++){
            intArray[j] = 0;
        }

        for(int i = 0 ; i < M ; i++){
            String[] STR2 = br.readLine().split(" ");
            int a = Integer.parseInt( STR2[0] );
            int b = Integer.parseInt( STR2[1] );
            int c = Integer.parseInt( STR2[2] );

            for(int k = a ; k <= b ; k++){
                intArray[k-1] = c;
            }
        }

        for(int j = 0; j < N ; j++){
            bw.write(String.valueOf(intArray[j]) + " ");
        }

        bw.flush();
        bw.close();
    }
}
profile
응애 나 애기 개발자
post-custom-banner

0개의 댓글