-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhappytelephones.py
44 lines (35 loc) · 1.19 KB
/
happytelephones.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
#coding happy telephones
while(True):
try:
start_time = []
end_time = []
start = []
end = []
input_ = raw_input().strip("\n").split(" ")
num_calls = int(input_[0])
num_intervals = int(input_[1])
#the last test case
if num_calls == 0 and num_intervals == 0:
break
#input the times
for i in range(0,num_calls):
times = raw_input().strip("\n").split(" ")
start_time.append(int(times[2]))
end_time.append(int(times[3])+start_time[i])
#take in the intervals police are interested in
for _ in range(0,num_intervals):
input_ = raw_input().strip("\n").split(" ")
start = int(input_[0])
end = int(input_[1])+start
#count calls that fall within the interval
cnt = 0
for i in range(0,num_calls):
if start >= end_time[i]:
pass
elif end <= start_time[i]:
pass
else:
cnt = cnt + 1
print cnt
except:
break