<filename>arc118_b.py
import math
k,n,m,*a=map(int,open(0).read().split())
mn=m/n
s=0
l=[]
for i,av in enumerate(a):
    v=av*mn
    s+=int(v)
    l.append((int(v)*n - av*m,v,i))
l.sort()
b=[0]*k
ms=m-s
for i in range(ms):
    _,v,j=l[i]
    b[j]=math.ceil(v)
for i in range(ms,k):
    _,v,j=l[i]
    b[j]=int(v)
print(' '.join(map(str,b)))

<filename>arc118_b.py
import math
k,n,m,*a=map(int,open(0).read().split())
mn=m/n
s=0
l=[]
for i,av in enumerate(a):
    v=av*mn
    s+=int(v)
    l.append((int(v)*n - av*m,v,i))
l.sort()
b=[0]*k
ms=m-s
for i in range(ms):
    _,v,j=l[i]
    b[j]=math.ceil(v)
for i in range(ms,k):
    _,v,j=l[i]
    b[j]=int(v)
print(' '.join(map(str,b)))
