codeforces educational round

could anyone suggest a simpler stategy for solving the
problem:http://codeforces.com/contest/863/problem/B

Just brute-force it, since N is very small. (N<= 50)

1 Like

You can use 2D DP and Sorting.

Here is link to my solution.

At any point, you can choose to find the difference between adjacent numbers or you can leave it.You must remember that you can leave atmost 2 numbers.

1 Like