Optimal resource allocation for carbon mitigation