fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.Scanner;
  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. Scanner scan = new Scanner(System.in);
  13. int size = scan.nextInt();
  14. long arr1[] = new long [size];
  15. long arr2[] = new long [size];
  16. for(int i = 0; i < size; i++){
  17. arr1[i] = scan.nextInt();
  18. }
  19. for(int i = 0; i < size; i++){
  20. arr2[i] = scan.nextInt();
  21. }
  22. long tmp = 0;
  23. for(int i = 0; i < size; i++){
  24. tmp+= Math.abs(arr2[i] - arr1[i]);
  25. }
  26. System.out.println (tmp / 2);
  27. }
  28. }
Success #stdin #stdout 0.07s 2184192KB
stdin
3
6 3 1
0 0 10
stdout
9