My issue
I am getting right output but its showing answer. I don’t what to do. Please help me out with this
My code
import java.util.*;
class Codechef
{
public static void main (String[] args)
{
Scanner read = new Scanner(System.in);
int t = read.nextInt();
for(int i=0; i<t; i++)
{
ArrayList<Integer> a = new ArrayList<Integer>();
ArrayList<Integer> b = new ArrayList<Integer>();
int n = read.nextInt();
for(int j=1; j<=n; j++){
int ele = read.nextInt();
a.add(ele);
}
for(int j=1; j<=n; j++){
int ele = read.nextInt();
b.add(ele);
}
// Update the code below to solve this problem
int count=0;
int res=0;
for(int j=0;j<n;j++)
{
if(a.get(j)>=b.get(j))
{
count++;
if(j==n-1)
break;
res+=a.get(j);
a.set(j+1,a.get(j+1)-res);
}
}
System.out.println(count);
}
}
}
Learning course: Placement preparation using Java
Problem Link: Practice Problem in - CodeChef