You're correct. Here is a solution worked out with variable names I'm more comfortable with. I substitute back some of your variable names at the end.
Prompt
Let there be a closed room of volume $V$ at indoor temperature $T_1$. It has
to be cooled down to temperature $T_2$. If $Q_{\text{out}}$ amount of heat is
removed from the room every second, then how much time will it take to reach
the desired temperature?
Assume $Q_{\text{in}}$ is the amount of heat input to the room every second.
Image by Baltakatei licensed CC BY-SA 4.0
Energy balance
First, consider an energy balance of the system.
$$
\left( \text{rate of energy in} \right) - \left( \text{rate of energy out}
\right) + \left( \text{rate of energy generation} \right) = \left(
\text{rate of energy accumulation} \right)
$$
$$Q_{\text{in}} - Q_{\text{out}} + 0 = \frac{dU}{dt} \cdot m$$
where:
\begin{eqnarray*}
Q_{\text{in}} & : & \text{rate of heat flow into the system} \left[
\tfrac{\text{J}}{\text{s}} \right]\\
Q_{\text{out}} & : & \text{rate of heat flow out of the system} \left[
\tfrac{\text{J}}{\text{s}} \right]\\
t & : & \text{time} \left[ \text{s} \right]\\
U & : & \text{internal energy of the system per unit mass} \text{} \left[
\tfrac{\text{J}}{\text{kg} \cdot \text{s}} \right]\\
m & : & \text{mass of system} \left[ \text{kg} \right]
\end{eqnarray*}
Solve for $dU$.
$$dU = \left( \frac{1}{m} \right) \cdot \left( Q_{\text{in}} - Q_{\text{out}}
\right) \cdot dt$$
Integrate from initial to final state.
\begin{equation}
\int_{U = U_i}^{U = U_f} dU = \frac{1}{m} \cdot \int_{t = t_i}^{t = t_f}
\left( Q_{\text{in}} - Q_{\text{out}} \right) dt
\end{equation}
\begin{equation}
U_f - U_i = \frac{1}{m} \cdot \left( Q_{\text{in}} - Q_{\text{out}} \right)
\cdot (t_f - t_i)
\end{equation}
Equation 1: Simplify with $\Delta U = U_f - U_i$.
\begin{equation}
\Delta U = \frac{1}{m} \cdot \left( Q_{\text{in}} - Q_{\text{out}} \right)
\cdot (t_f - t_i)
\end{equation}
Temperature change from heat flow.
For a mechanically reversible constant-volume process, $Q = m \cdot \Delta U$.
Take into account changes in temperature of the system mass by introducing the
concept of constant-volume heat capacity. The definition of constant-volume
heat capacity of a substance (provided by Introduction to Chemical
Engineering, 7th Edition, by J.M. Smith) is:
\begin{equation}
C_V \equiv \left( \frac{dU}{dT} \right)_V
\end{equation}
Where:
\begin{eqnarray*}
C_V & : & \text{constant volume heat capacity} \left[
\tfrac{\text{J}}{\text{kg} \cdot \text{K}} \right]\\
T & : & \text{temperature of the system} \left[ \text{K} \right]\\
V & : & \text{specific volume of the system} \left[
\tfrac{\text{m}^3}{\text{kg}} \right]
\end{eqnarray*}
\begin{equation}
dU = C_V dT
\end{equation}
\begin{equation}
\int_{U = U_i}^{U = U_f} dU = \int_{T = T_i}^{T = T_f} C_V dT
\end{equation}
\begin{equation}
U_f - U_i = C_V \cdot (T_f - T_i)
\end{equation}
Equation 2: Substitute $\Delta U = U_f - U_i$ :
\begin{equation}
\Delta U = C_V \cdot (T_f - T_i)
\end{equation}
Combine energy rate balance equation with energy-temperature equation
Now we have an expression (equation 2) for how the internal energy
of the constant-volume system changes with temperature. We also have an
expression (equation 1) for how internal energy changes according to
heat flows $Q_{\text{in}}$ and $Q_{\text{out}}$. These two changes in internal
energy are equal so we set equation 1 and equation 2 equal
to one another, yielding equation 3:
\begin{equation}
\Delta U = \frac{1}{m} \cdot \left( Q_{\text{in}} - Q_{\text{out}} \right)
\cdot (t_f - t_i) = C_V \cdot (T_f - T_i)
\end{equation}
Solve for $t_f$.
\begin{equation}
t_f = \frac{C_V \cdot m \cdot (T_f - T_i)}{Q_{\text{in}} - Q_{\text{out}}} +
t_i
\end{equation}
Now, apply the prompt's parameters.
\begin{eqnarray*}
T_i & = & T_1 \\
T_f & = & T_2 \\
t_i & = & 0 \\
Q_{\text{in}} & = & D \\
Q_{\text{out}} & = & Q \\
\end{eqnarray*}
\begin{equation}
t_f = \frac{C_V \cdot m \cdot (T_2 - T_1)}{D - Q}
\end{equation}
Equation 4. Multiply by $\frac{-1}{-1}$
\begin{equation}
t_f = \frac{C_V \cdot m \cdot (T_1 - T_2)}{Q - D}
\end{equation}
Summary
Equation 4 is the amount of time required to cool mass $m$ from
$T_1$ to $T_2$, provided the constant-volume specific heat capacity $C_V$ is
known as well as the heat flows to ($Q_{\text{in}}=D$) and from
($Q_{\text{out}}=Q$) the rigid container.
A PDF draft of this solution is here.