Quantum brachistochrone problem for a spin-1 system in a magnetic field