-
Notifications
You must be signed in to change notification settings - Fork 4
/
conference-schedule.py
55 lines (41 loc) · 1.24 KB
/
conference-schedule.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
50
51
52
53
54
55
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'maxPresentations' function below.
#
# The function is expected to return an INTEGER.
# The function accepts following parameters:
# 1. INTEGER_ARRAY scheduleStart
# 2. INTEGER_ARRAY scheduleEnd
#
def maxPresentations(scheduleStart, scheduleEnd):
# Write your code here
sl = sorted((list(zip(*[scheduleStart, scheduleEnd]))), key = lambda x:x[1])
sl = list(zip(*sl))
lim = sl[1][0]
n = 1
for i in range(1, len(scheduleEnd)):
if sl[0][i] >= lim:
n += 1
lim = sl[1][i]
# print(sl[0][i], sl[1][i])
return n
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
scheduleStart_count = int(input().strip())
scheduleStart = []
for _ in range(scheduleStart_count):
scheduleStart_item = int(input().strip())
scheduleStart.append(scheduleStart_item)
scheduleEnd_count = int(input().strip())
scheduleEnd = []
for _ in range(scheduleEnd_count):
scheduleEnd_item = int(input().strip())
scheduleEnd.append(scheduleEnd_item)
result = maxPresentations(scheduleStart, scheduleEnd)
fptr.write(str(result) + '\n')
fptr.close()