I am unable to understand what is wrong in my java code please help!

import java.util.Scanner;

 class Solution {
   public static void main(String args[]){
      double t,mincost=-1,p=0;
      int cas=0;
      double[][] c=new double[50][2];
      Scanner sc=new Scanner(System.in);
      t=sc.nextInt();
      double A[]=new double[2];
      double B[]=new double[2];
      double C[]=new double[2];
      double D[]=new double[2];



      while(cas!=t){
         int n=sc.nextInt();
         for(int i=0;i<n;i++){
            c[i][0]=sc.nextInt();
            c[i][1]=sc.nextInt();

         }
         for(int i=0;i<n;i++){
            A[0]= c[i%n][0];
            A[1]= c[i%n][1];

            B[0]= c[(i+1)%n][0];
            B[1]= c[(i+1)%n][1];

            C[0]= c[(i+2)%n][0];
            C[1]= c[(i+2)%n][1];

            D[0]=c[(i+3)%n][0];
            D[1]=c[(i+3)%n][1];
            p=area(A,B,C,D);
            p*=2;
            if(i==0) mincost=p;
            else if(p<mincost) mincost=p;


         }
         System.out.println("Case #"+(cas+1)+":"+(long)mincost);
         cas++;
      }

   }
   static double area(double A[],double B[],double C[],double D[]){

      double l1=A[0]*B[1]+B[0]*D[1]+D[0]*A[1];
      double r1=A[1]*B[0]+B[1]*D[0]+D[1]*A[0];
      double t1=Math.abs((l1-r1)/2);

      double l2=B[0]*D[1]+D[0]*C[1]+C[0]*B[1];
      double r2=B[1]*D[0]+D[1]*C[0]+C[1]*B[0];
      double t2=Math.abs((l2-r2)/2);
      return t1+t2;
   }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/35056292-cf7d-46d3-9a3b-9dd7ade35c52%40googlegroups.com.

Reply via email to