SWEA 5789 현주의 상자 바꾸기

1 개요[ | ]

SWEA 5789 현주의 상자 바꾸기
SW Expert 아카데미
# 문제 풀이

틀:SWEA 난이도 3-1

2 C++[ | ]

3 Java[ | ]

import java.util.*;
class Solution {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int T;
        T=sc.nextInt();
         
        int N, Q, L, R, i, j;
        int[] box;
        for(int test_case = 1; test_case <= T; test_case++) {
            N = sc.nextInt();
            Q = sc.nextInt();
            box = new int[N+1];
            for(i=1; i<=Q; i++) {
                L = sc.nextInt();
                R = sc.nextInt();
                for(j=L; j<=R; j++) {
                    box[j] = i;
                }
            }
            System.out.format("#%d", test_case);
            for(i=1; i<=N; i++) {
                System.out.format(" %d", box[i]);
            }
            System.out.println();
        }
        sc.close();
    }
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}