Sharp regularity results for functionals with (p,q) growth