Efficient Allocation of Working Memory Resource for Utility Maximization in Humans and Recurrent Neural Networks