Optimal resource allocation of networked epidemic models