Given a set of resource constraints, write an algorithm to optimize the allocation of background jobs across a cluster of virtual machines.