In motion solving question of motion under gravity there are two methods to solve those questions
1. First method is sign convention like taking upward direction as positive and downward direction as negative, that whatever tha measurement we take along upward as positive whether it can be velocity or displacement and measurement along downward is taken as negative,. You can also change sign convention according to convenience.
For the given question it was already declared that upward direction is positive so the downward direction will be negative, and you must know acceleration due to gravity always acts toward the centre of the earth (downward ). Since it is acting downward then it will be taken as negative. And its direction is fixed so it will always be negative for the entire motion
2. Other method is taking acceleration direction as direction of reference . So the quantity measured along the direction of acceleration will taken as positive and against will be taken as negative. This method is use to solve horizontal rectilinear motion. Like car is running on road.