SPOJ - ABCDEF, Binary Search Problem - WA

Getting WA, Where am i wrong? Here’s the problem and code:

Problem: https://www.spoj.com/problems/ABCDEF/
Code: https://ide.codingblocks.com/s/76324/

Where can i post queries related to challenges? should the queries must be related to the current videos?

for(int d=0;d<n && v[d]!=0;d++){
fed.push_back(v[d]*(v[f]+v[e]));
}
this is the problem bro!
after v[d]=0; your loop breaks , therefore not calculating other values after v[d]=0.
ex -:
5
1 2 0 3 4
now values of d=3 and d=4 are not being calculated .
use that condition inside the for loop.

1 Like

Thanks! That Fixed it! I wanna slap my self now… :sweat_smile::joy: such a silly mistake. Thanks again!

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

1 Like