-
Notifications
You must be signed in to change notification settings - Fork 7
/
hackerrank_max_subset_by_sum.py
54 lines (46 loc) · 1 KB
/
hackerrank_max_subset_by_sum.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
# n, k = [int(x) for x in input().strip().split()]
# a = [int(x) for x in input().strip().split()]
# sorted(a)
#
# dict1 = {}
#
#
# def pass_it(x, y):
# for z in y:
# if (z + x) % k == 0:
# return False
# return True
#
# for x in a:
# if(x not in dict1):
# dict1[x]=[x]
# for y in a:
# if(y!=x):
# tof = pass_it(y, dict1[x])
# if (tof):
# dict1[x].extend([y])
#
# else:
# pass
# max_l=0
# for x in dict1:
# if(len(dict1[x])>max_l):
# max_l=len(dict1[x])
# print(max_l)
n, k = [int(x) for x in input().strip().split()]
a = [int(x) for x in input().strip().split()]
def pass_it(x, y):
if (y + x) % k == 0:
return False
return True
dict1={}
for x in a:
dict1[x]=[x]
max_l=0
for x in dict1:
for y in dict1:
if x!=y:
if(pass_it(x,y)):
dict1[x].extend([y])
max_l=len(dict1[x]) if len(dict1[x])>max_l else max_l
print(max_l)