-
Notifications
You must be signed in to change notification settings - Fork 0
/
boj_1931_greedy.py
53 lines (41 loc) · 1.07 KB
/
boj_1931_greedy.py
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
import sys
input = sys.stdin.readline
n = int(input())
time_table = []
for i in range(n):
time_table.append(list(map(int, input().rstrip().split(" "))))
time_table.sort(key = lambda x : x[1])
# print(time_table)
meeting_count = 0
end_time = False
cur_time = 0
pos = 0
st = 0
en = 0
# print(time_table)
while end_time == False:
print("--")
print([st,en,pos,meeting_count])
print(time_table[pos])
cur_time += 1
if st < cur_time and cur_time < en:
continue
if pos == len(time_table) - 1:
end_time = True
last_meeting_time = time_table[pos][1]
same_meetings = []
same_meetings.append(time_table[pos][0])
for i in range(pos + 1, len(time_table)):
if time_table[i][1] == last_meeting_time:
same_meetings.append(time_table[i][0])
else:
break
for time in same_meetings:
if time > en:
st = time
en = last_meeting_time
meeting_count += 1
break
print([pos, cur_time, meeting_count])
pos +=1
print(meeting_count)