15593

#include <stdio.h>
#include <stdlib.h>

int main(void){
    // 직원 인원수 입력
    int staff_num = 0;
    scanf("%d", &staff_num);

    int (*staff_time)[2] = (int(*)[2])malloc(sizeof(int)*staff_num*2);
    // 직원 시작 시간, 종료 시간 입력 후 저장
    for(int i = 0; i < staff_num; i++){
        int start = 0, end = 0;
        scanf("%d %d", &staff_time[i][0], &staff_time[i][1]);
    }

    // 직원 1명을 뺏을 때 최대 시간 구하기
    int max = 0;
    for(int i = 0; i < staff_num; i++){
        int time = 0;
        int arr[1000] = {0};

        int t = 0, count = 0;
        for(int j = 0; j < staff_num-1; j++){
            // 뺄 직원의 인덱스 번호이면 ++ 해주기
            if(t == i){
                t++;
            }
            
            // 현재 직원의 시작시간 부터, 종료 시간 까지 배열 채워서
            // 시간 count하기
            for(int k = staff_time[t][0]; k < staff_time[t][1]; k++){
                // 단, 시간이 채워지지 않았을 때만 count 증가 가능
                if(arr[k] == 0){
                    count++;
                    arr[k] = 1;
                }
            }
            t++;
        }

        // 만약 현재 count가 최대 시간보다 크면 max를 현재 count로 바꿔주기
        if(max < count){
            max = count;
        }
    }

    // 출력
    printf("%d", max);

    free(staff_time);
    return 0;
}

+ Recent posts