fix case where the number of processes is lower than the number of resources
* consider only the first n resources when n processes are available