[プログラマー]中秋節の流量


import java.util.*;

class Solution {
    public int solution(String[] lines) {
        int answer = 0;
        int size = lines.length;
        Info[] arr = new Info[size];
        StringTokenizer st,st1;
        
        //시작, 끝 시간 입력받기
        for(int i=0; i<size; i++){
            st = new StringTokenizer(lines[i]);
            st.nextToken();
            st1 = new StringTokenizer(st.nextToken(),":.");
            
            int end = Integer.parseInt(st1.nextToken())*3600*1000 +Integer.parseInt(st1.nextToken())*60*1000+Integer.parseInt(st1.nextToken())*1000+Integer.parseInt(st1.nextToken());
            
            st1 = new StringTokenizer(st.nextToken(),"s");
            int work = (int)(Double.parseDouble(st1.nextToken())*1000);
            
            
            int start = end-work+1;
            arr[i] = new Info(start, end);
        }
        
        //모든 객체를 각각 확인함.
        for(int i=0; i<arr.length; i++){
        		
            answer = Math.max(answer, count(arr[i].start, arr, i));
            answer = Math.max(answer, count(arr[i].end, arr, i));
        }
        
        
        
        return answer;
    }
    //시작 끝 시간을 가지는 객체
    public class Info{
        int start;
        int end;
        
        public Info(int start, int end){
            this.start = start;
            this.end = end;
            
        }
    }
    
    //1초안에 포함될 수 있는 다른 객체를 찾는 함수
    int count(int start, Info[] arr, int i){
        int end = start + 1000;
        int cnt = 1;
        for(int j=0; j<arr.length; j++){
            if(i==j) continue;
            if( arr[j].end < start || arr[j].start >= end ) continue;
            cnt++;
        }
        return cnt;
    }

}