Let B be turned off after \( t \) minutes. The amount of water filled by A in 20 minutes:
A's rate \( = \frac{1}{32} \), B's rate \( = \frac{1}{48} \).
Water filled by A in 20 minutes: \( \frac{20}{32} \).
The amount of water filled by B in \( t \) minutes:
Water filled by B: \( \frac{t}{48} \).
The total water filled should equal 1 tank:
\[ \frac{20}{32} + \frac{t}{48} = 1. \]
Simplify:
\[ \frac{5}{8} + \frac{t}{48} = 1 \implies \frac{t}{48} = \frac{3}{8}. \]
\[ t = \frac{3}{8} \times 48 = 18. \]
Thus, pipe B should be turned off after 18 minutes.