-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddingSquares.py
More file actions
39 lines (37 loc) · 903 Bytes
/
AddingSquares.py
File metadata and controls
39 lines (37 loc) · 903 Bytes
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
def fun(X, Y, N, M):
m1 = {}
m2 = {}
ans = 0
for i in range(0, N):
for j in range(i + 1, N):
dist = abs(X[i] - X[j])
if dist in m1:
m1[dist] = m1[dist] + 1
else:
m1[dist] = 1
for i in range(0, M):
for j in range(i + 1, M):
dist = abs(Y[i] - Y[j])
if dist in m2:
m2[dist] = m2[dist] + 1
else:
m2[dist] = 1
for key in m1:
if key in m2:
ans +=1
return ans
l=list(map(int,input().split()))
w=l[0]
h=l[1]
n=l[2]
m=l[3]
A=list(map(int,input().split()))
B=list(map(int,input().split()))
t=fun(A,B,len(A),len(B))
temp=[]
for i in range(1,h+1):
if i not in B:
B.append(i)
temp.append(fun(A,B,len(A),len(B))-t)
B.remove(i)
print(max(temp)+t)