-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCOPS.py
42 lines (24 loc) · 991 Bytes
/
COPS.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
# cook your dish her
if __name__=='__main__':
t = int(input())
for _ in range(t):
m, x, y = map(int, input().rstrip().split())
cops_houses = list(map(int, input().rstrip().split()))
cops_houses.sort(reverse = True)
max_range = x*y
unsafe_houses = [0]*101
total_houses = 100
for i in range(m):
j = cops_houses[i]
k = cops_houses[i]
while((j <= (cops_houses[i] + max_range)) and (j <= 100)):
unsafe_houses[j] = 1
j += 1
while((k >= (cops_houses[i] - max_range)) and (k >= 1)):
unsafe_houses[k] = 1
k -= 1
safe = 0
for i in range(1, 101):
if unsafe_houses[i] == 0:
safe += 1
print(safe)