Perfect competition profits question Market is supplied by: 50 competitive companies all of them have relatively low costs given by an equation $C_l(q)=350+2q+q^2$ and by n companies of higher costs given by an equation $C_h(q)=400+2q+q^2$. Market demand is given by $Q=250-10P$. If none of the companies with higher costs will  gain positive profits, how large is n? What is the profit of companies with low costs?

I have no idea how to solve this question, i do not know how to start.
It says


  If none of the companies with higher costs will gain positive profits


I assume this means they're making 0 profits, while strictly speaking it could mean that they make negative profits and leave the market.


So with 0 profits, this means that average costs = price for the high-cost firms.


First, you need to derive the equilibrium price, using that, for the equilibrium price, demand = supply.

$$ \text{total demand} = Q(p) = S(p) = \text{total supply}$$

A firm's supply is the solution to a maximization problem:

$$ q_h(p) = \arg\max_q (p-C_h(q))q \\
 q_l(p) = \arg\max_q (p-C_l(q))q$$

Then, total supply given price $p$ and amount of high-cost firms $n$ is 

$$ S(p, n) = 50\cdot q_l(p) + n \cdot q_h(p)$$

Then, our equilibrium condition is simply

$$ S(p, n) = Q(p) $$

This is under defined, as we have one equation and two variables $(p, n)$ to solve for. But wait, we know more! 0 profits for the high-cost firms means

$$ p = C_h(q)$$

To get rid of the additional variable $q$, just use the solution to the firm's problem: 

$$ p = C_h(q_h(p))$$

Now we have two equations and two variables, you are all set!

$$ S(p, n) = Q(p) \\
 p = C_h(q_h(p))$$