fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. // your code goes here
  13. //For finding the minimum sum of two arrays
  14. int a1=2,a2=3,a3=4,a4=5,a5=7; // Strictly increasing (ascending)
  15. int b1 =7,b2=5,b3=4,b4=2,b5=1; // descending
  16.  
  17. int g = a1*b1 + a3*b3 + a5*b5;
  18. int sum1 = g + a2*b2 + a4*b4;
  19. int sum2 = g + a4*b2 + a2*b4;
  20. int d =0;
  21. if(sum1>sum2){
  22. d = sum1 - sum2;
  23. }
  24. else {
  25. d= sum2 -sum1;
  26. }
  27.  
  28. System.out.println(d);
  29. }
  30. }
Success #stdin #stdout 0.1s 54612KB
stdin
Standard input is empty
stdout
6