Chimpanzees, like many humans, perform better at complex tasks when there is an audience watching, scientists have found.