An optimal algorithm for the Thresholding Bandit Problem