Source Code
a , b = input("").split(" ")[:2]
a = int(a)
b = int(b)
d = input("").split(" ")

c = [int(i) for i in d]


if(c.count(0) >= int(a/b)):
    lists[0] = [0 for i in range(c.count(0))]
    for i in range(c.count(0)):
        c.delete(0)
        
lists = [[] for i in range(b)]
            

for i in range(int(a/b)):
    if(b==1):
        break
    else:
        for i in range(b):
            lists.append(list())
            lists[i].append(min(c))
            c.remove(min(c))

mex = []

for i in range(b):
    if(b==1):
        break
    min = 0 
    while(min in lists[i]):
        min = min+1
    mex.append(min)
    
if(b==1):
    min = 0
    while(min in c):
        min = min + 1
    
    
   
if(b==1):
    print(min)
else:
    print(sum(mex))
Copy
Bitar The Handy Man cheesy
Python 3
32 ms
6.1 MB
Runtime Error