SWEA 6485 삼성시의 버스 노선

1 개요[ | ]

SWEA 6485 삼성시의 버스 노선
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, i, j, P, C, count;
        int[] A, B;
        for(int test_case = 1; test_case <= T; test_case++) {
            N = sc.nextInt();
            A = new int[N+1];
            B = new int[N+1];
            for(i=1; i<=N; i++) {
                A[i] = sc.nextInt();
                B[i] = sc.nextInt();
            }
            P = sc.nextInt();
            System.out.format("#%d", test_case);
            for(i=1; i<=P; i++) {
                C = sc.nextInt();
                count = 0;
                for(j=1; j<=N; j++) {
                    if(A[j] <= C && C <= B[j]) count++;
                }
                System.out.format(" %d", count);
            }
            System.out.println();
        }
        sc.close();
    }
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}