Well we have to solve system of equations.

Lets say h is total number of high quality balls and l is total number of low quality balls.

So h+l must be 160.

So we can set system:

36*h + 20*l = 3840

h+l=160

36*h + 20*l = 3840

h=160-l

36(160-l) + 20*l = 3840

5760-36l+20l=3840

5760-3840=36l-20l

1920=16l

l=120

So h+120=160

h=40

So we can by 40 high quality balls and 120 low quality balls.