EURON Problem DSA

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

Why Iam Getting WA??

read question carefully.

I’m also getting wrong answer.Could you please provide any test case where my code might be failing? are all elements of the array distinct?

No all elements are not distinct.
It might be that you are interpreting the question wrongly so read the question carefully.

sample test case:
8
4 5 5 6 7 7 1 1
output:
12

1 Like

Can you please explain how did you get 12?

after receving every element of array we will check for voilation so
arr=4 ----------------------------- voilation = 0
arr=4 5 ---------------------------voilation = 0
arr=4 5 5 ------------------------voilation = 0
arr=4 5 5 6 --------------------- voilation = 0
arr=4 5 5 6 7------------------- voilation = 0
arr=4 5 5 6 7 7 -----------------voilation = 0
arr=4 5 5 6 7 7 1 ---------------voilation = 6
arr=4 5 5 6 7 7 1 1 ------------voilation = 12

or

in array 4 5 5 6 7 7 1 1 both 1 are appearing after 6 integer which is greater than 1

2 Likes