ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • 백준 10810 JAVA
    ETC/Algorithm 2023. 5. 19. 23:13
    import java.io.*;
    import java.util.StringTokenizer;
    
    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));
    
            StringTokenizer st;
    
            st = new StringTokenizer(br.readLine(), " ");
    
            int n = Integer.parseInt(st.nextToken());
            int m = Integer.parseInt(st.nextToken());
    
            int[] bucket = new int[n];
    
            for (int t = 0; t < m; t++) {
                st = new StringTokenizer(br.readLine(), " ");
    
                int i = Integer.parseInt(st.nextToken()) - 1;
                int j = Integer.parseInt(st.nextToken()) - 1;
                int k = Integer.parseInt(st.nextToken());
    
                for (int y = i; y <= j; y++) {
                    bucket[y] = k;
                }
            }
            for (int number : bucket) {
                bw.write(number + " ");
            }
            bw.flush();
        }
    }

    댓글

Designed by black7375.