My issue
Code gets correct output but while submitting I am getting wrong
My code
/* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Scanner(System.in);
int sum=0;
int t=sc.nextInt();
for(int i=1;i<=t;i++)
{
int A=sc.nextInt();
int B=sc.nextInt();
int a[]=new int[A];
a[0]=0;
for(int k=0;k<A;k++)
{
a[k]=sc.nextInt();
}
for(int j=0;j<A;j++)
{
if(j>=1)
{
if(a[j]==1 || a[j-1]==1)
{
sum=sum+B;
}
}
else if(j==0)
{
if(a[j]==1)
{
sum=sum+B;
}
}
}
System.out.println(sum);
}
}
}
Problem Link: CodeChef: Practical coding for everyone