Diffusion Models as Optimizers for Efficient Planning in Offline RL