Anyone knows why my answer is wrong? I use this formula

ans * (x + 1) + (n - ans) * v = tot v : [0, m] ans: [0, n]

so ans = (tot - n * v) / (x + 1 - v)

and find the valid answer

https://www.codechef.com/viewsolution/64243153

https://www.codechef.com/viewsolution/64242973

If there are n people, and the average is x, then the total sum of marks they’ve obtained is n*x. Now, to beat the average by a bare minimum, you need y number of people with average x+1. Your total sum is n*x, and each person would need x+1, so the maximum amount of people would be floor(n*x/(x+1))