$\textbf{In short}$
No, there are a number of issues. see section 1 below for the solution, and section 2 for some intuition behind why this process works.
$\textbf{section 1 - Potential Problems}$
$\underline{Objective \ function \ setup}$
Your objective function is the function that you are interested in, in your question it is profit.
It appears that there is a wrong sign on your cost function. Costs take away from profits, they don't add to profits. i.e. $$ \pi = revenue \color{red}{-} costs, \ where\ \pi \ is \ profit$$
$\underline {Inverse \ Demand, y(p)=a-bp}$
Another issue is that in a typical monopoly question, output(i.e. y) is a function of price (i.e. $y(p) $) and inversely price is a function of output (i.e. $p(y) $).
This occurs because there is one firm in the market, and thus the firm faces the entire market demand. This means that the firm $\textbf{is not a price taker}$, but every price it sets has an effect on the quantity demanded, and results in the firm's price $\textbf{being the demand curve}$ (called the inverse demand curve).
For example.
Suppose we had a market with consumers having a demand function of
$$y_d(p)=a-bp $$
Thus, this would result in the objective function
$$ max_{p} \ \pi = p\times y_d(p) - C(y) $$
One issue with this is that your costs function is now a function of price, because it is a function of output which is a function of price.
i.e. $ C(y(p)) $ , to solve this you would need to a.) implicitly derive or b.) substitute y(p) for it's function (e.g $C(a-bp)$, if available). I think young's theorem might have something to say on this.
$\textbf{Now we have a valid profit function for a monopoly!!}$
$$ max_{p} \ \pi = \color{red}{ p \times y_d(p)} - \color{blue}{C(a-bp)} $$
now we can optimise;
$\underline{First \ order \ conditions}$
$$ \frac{\partial \pi}{\partial p} = \color{red}{(1\times y_d(p) + p \times y_d'(p) )} - \color{blue}{\frac{d}{dp}(C(a-bp))}$$
NB, you have to apply chain rule to derive $ p \times y_d(p) $ hence the term in red on the left.
Set $ \frac{\partial \pi}{\partial p} = 0$ and solve for p.
By setting this equal to zero, $\color{red}{marginal \ revenue}$ equals $\color{blue}{marginal \ cost}$ with respect(in terms of) to p. Thus, this is where profit is maximised.
$ \textbf{voila} $
Now you have the optimal price
$\textbf{section 2 - Intuition}$
This works because you are using the process of optimisation on the profit function, to find the best price.
The process of taking the max or min of a function is referred to as optimisation in mathematics. It helps find the largest (max) or smallest (min) value in the objective function (profit in your case). This works because taking the derivative of a function essentially treats your objective function as a curve with respect to the variable you are interested in, and in taking the derivative allows you to find the peaks(max values) and the troughs(min values) of your objective function. Hence in your example, you are treating profit as a curve and finding the point on that curve with the largest p value.