Getting wa in sticks

https://www.codechef.com/submit/STICKS
https://www.codechef.com/viewsolution/36615531

please tell me where i’m wrong

Your case is failing when there are 4 sticks of the biggest no. I.e. that no. Can make square .
Eg. test case
1
8
7 7 7 7 4 4 3 3
The answer is 49 as 7 can make all the 4 sides and a square is also a rectangle

2 Likes

oh, thanks i’m solving this problem in the perspective of rectangle and neglecting square

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

i have optimised my solution but still getting wa