FAIRELECT answer wrong

When i run my code with custom inout or without custom input it shows successfully executed but when I submit it shows wrong ans
here is the question: Fair Elections | CodeChef
here is my solution: Solution: 41604564 | CodeChef

read editorial

2 Likes

make a check on j inside for loop for j>=0; else code will give wrong answer

for(i=0;i<n;i++){
                j=m-1;
	            nsum=nsum-narr[i]+marr[j];
	            msum=msum-marr[j]+narr[i];
	            c++;
                j--;
	            if(nsum>msum){
	                value=1;
	                break;
	            }
                    if(j <0) break; //ADD THIS TO YOUR CODE
	        }

for(i=0,j=m-1;i<n;i++,jā€“){

            nsum=nsum-narr[i]+marr[j];
            msum=msum-marr[j]+narr[i];
            c++;
        
            if(nsum>msum){
                value=1;
                break;
            }

i changed my code to this
still the same issue
on submitting it says wrong ans

it is j-- i have j-- in my code still issue