Help in MAXSC..??

I read the editorial and i was implementing the same concept.

but i was getting wa. Can someone explain to me how is my code wrong?

link to my code: https://www.codechef.com/viewsolution/17024899

That is due to your function get_max(4 parameters)

U should store the maximum valid value,not the maximum .

I mean consider that x=4 and u are searching in this array

1 7 3

So ur fundtion will give output 1,while it should be 3

(Do this

If(arr[i]<x) m=max(m,arr[i])
)

Thanks. It worked…!!