Synthesis of Cost-Optimal Multi-Agent Systems for Resource Allocation