Can't understand which test cases I am getting wrong (SFRV)

Hey, I solved the second problem(SFRV) of July_Lunchtime19 & can’t understand where I am getting wrong.
I haven’t solved it by DP as in editorial, but with simple arrays.
The problem link and solution has been attached.

Can anyone help me out ?
Problem SFRV @ltime77
My Solution

I tried with some test cases…and the answer matched with that of the editorials solution…but still WA.

generate thousands of random inputs, run your code, and correct code on them, and compare, you’ll find failing cases quickly :slight_smile:
Without DP you’ll obviously get WA

Consider the following testcase:
1
5
6 3 4 5 3
Your code gives answer 62 but correct answer is 64.
Swapping 1&2 and 4&5.
Hope you got the mistake.

1 Like

Thank you so much @pulkit_mittal.

1 Like