https://www.codechef.com/problems/EXUNA

the problem tries to maximise the function F(perm(A1,A2,A3,…))

here’s my solution:

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

any help would be appreciated

Let M be the minimum number in the permutation.

What is answer when M is the first number in permutation?

What happens when M is at any other position? Hint: x \pmod y \lt y

1 Like