For this Question: N+1 towns are going to be attacked by monsters. The i-th town will be attacked by Ai monsters. Saloni has got N of her friends for rescue. The i-th friend has the capability to kill at most Bi monsters. The only constraint is that the i-th friend can kill monsters from town i and i+1 only.
Find the maximum number of monsters the friends can kill.The first line of input contains an integer N.
The next line contains N+1 integers Ai.
The next line contains N integers Bi.

Constraints
1 <= N <= 100000
1 <= Ai, Bi <= 1000000000Output a single integer, the maximum number of monsters that can be killed.Sample Input
2
3 5 2
4 5

Sample Output
9

Explanation
The first friend will kill 2 monsters from town 1 and 2 monsters from town 2.
The second friend will kill 3 monsters from town 2 and 2 monsters from town 3.

Sample Input:
2
100 1 1
1 100

Sample Output:
3, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
    public static void main (String[] args)throws IOException {



















        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
    int t=Integer.parseInt(buf.readLine());
    String []inp=buf.readLine().split(" ");
    String []inp1=buf.readLine().split(" ");
    int []a=new int[inp.length];
    int []b=new int[inp.length];
    for(int i=0;i<inp.length;i++)a[i]=Integer.parseInt(inp[i]);
    for(int i=0;i<inp1.length;i++)b[i]=Integer.parseInt(inp1[i]);
       long ans=0;
    int last=0;
       for(int i=0;i<b.length;i++)
    {
      int r=a[i];
      int s=b[i];
      r-=Math.min(r,last);
      int k=Math.min(r,s);
      r-=k;
      last=s-k;
      ans+=a[i]-r;
    }
    ans+=Math.min(a[inp.length-1],last);
    System.out.println(ans);

    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?