fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.text.*;
  5. import java.io.*;
  6. import java.math.*;
  7. import java.util.regex.*;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class Ideone
  11. {
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. int s_boys[] = {-1,2};
  15. int s_girls[] = {0,2};
  16. int m=2;
  17.  
  18.  
  19. int i,j;
  20. int bmpos=-1,bmax=-1;
  21. int gmpos=-1,gmax=-1;
  22. int rep=0;
  23.  
  24. for(i=0;i<s_boys.length;i++)
  25. {
  26. if(Math.abs(s_boys[i])>bmax)
  27. {
  28. bmax = Math.abs(s_boys[i]);
  29. bmpos = i;
  30. }
  31. }
  32.  
  33. for(i=0;i<s_girls.length;i++)
  34. {
  35. if(Math.abs(s_girls[i])>gmax)
  36. {
  37. gmax = Math.abs(s_girls[i]);
  38. gmpos = i;
  39. }
  40. }
  41.  
  42. for(i=0;i<s_boys.length;i++)
  43. rep=rep+s_boys[i]*s_girls[i];
  44.  
  45. if(gmax>bmax)
  46. rep=rep+gmax*m;
  47. else
  48. rep=rep+bmax*m;
  49.  
  50. System.out.println(rep);
  51.  
  52. }
  53. }
Success #stdin #stdout 0.06s 320576KB
stdin
Standard input is empty
stdout
8