An ideal observer analysis of visual short-term memory: Evidence for flexible resource allocation