General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
121169846 Virtual:
vinay272001#
999D - 32 Python 3 Accepted 1060 ms 21856 KB 2021-07-03 11:23:24 2021-07-03 11:23:24
→ Source
n, m = map(int, input().split())
a = list(map(int, input().split()))
s = sum(a)
x = [[] for i in range(m)]
for i in range(n): 
    x[a[i] % m].append(i)
j = 0
for i in range(m):
    while len(x[i]) > n // m:
        while j < i or len(x[j % m]) >= n // m: 
            j += 1
        k = x[i].pop()
        a[k] += (j - i) % m
        x[j % m].append(k)
print(sum(a) - s)
print(*a)
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details