Getting wrong answer

Code

since the constraints are large convert int to long long int

and also, do not sort ,since the painting is dependent on the input array

inorder to find the maximum element in the array
while iterating find s = max(s , board[i])
updated code

Sir , not understand why to remove sort function ?

see because the painters can paint only in contigous manner, and not randomly.
So if we sort the array then the condition of:
Every painter can paint only contiguous segments of boards. which is mentioned in the question is violated

Hence we cannot sort the array