Read the pages problem

Input Format:
First line contains integers, N and M, denoting the number of books and number of students respectively. Next line contains N integers, denoting the number of pages in N books.

Constraints:
1<=N<=10^5 1<=M<=N 1<=Pi<=10^9

1

In one of the test cases, the constraint M<=N is not maintained, what should be done in such case?

as mention in testcase

it should not be in testcase but if it is then
in such case ans should be arr[n-1] means max pages
and 101th student read none

Okay. Thank you.

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.