1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
| import java.util.*;
class Traffic {
int start;
int end;
Traffic(int start, int end){
this.start = start;
this.end = end;
}
}
class Solution {
static int[] DPM;
public int solution(String[] lines) {
int answer = 0;
int temp_min = -1;
int bool_CNT = 0;
boolean second_to_minORhour = false;
List<Traffic> t_list = new ArrayList();
for(int i = 0; i < lines.length; i++) {
String s1 = lines[i].substring(17, 23);
String s2 = lines[i].substring(24, lines[i].length() - 1);
int start = (int)(Double.parseDouble(s1) * 1000 - Double.parseDouble(s2) * 1000) + 1;
int end = (int)(Double.parseDouble(s1) * 1000);
if(temp_min > end)
{
second_to_minORhour = true;
bool_CNT++;
}
if(second_to_minORhour)
{
t_list.add(new Traffic(start + 60000 * bool_CNT, end + 60000 * bool_CNT));
}
else
{
t_list.add(new Traffic(start, end));
}
temp_min = end;
}
int max = 1;
for(int i = 0; i < t_list.size(); i++) {
Traffic t = t_list.get(i);
int cnt = 1;
for(int j = i + 1; j < t_list.size(); j++)
{
if(t.end + 1000 > t_list.get(j).start)
cnt++;
}
if(max < cnt)
max = cnt;
}
answer = max;
return answer;
}
}
|