Guest User

Untitled

a guest
Oct 16th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class DanceFloor {
  4. public static void main(String[] args) {
  5.  
  6. Scanner scan = new Scanner(System.in);
  7. System.out.println();
  8. int n = scan.nextInt();
  9. int c_temp = 0;
  10. int[] arr_temp = new int[n];
  11. int[][] arr = new int[n][2];
  12. for (int i = 0; i < n; i++) {
  13. for (int j = 0; j < 2; j++) {
  14. arr[i][j] = scan.nextInt();
  15. //System.out.println(arr[i][j]);
  16. }
  17. if ((arr[i][0] % 2 == 0 && arr[i][1] % 2 == 0) || (arr[i][0] % 2 != 0 && arr[i][1] % 2 != 0)) {
  18. arr_temp[c_temp] = i;
  19. //System.out.println(arr_temp[c_temp]);
  20. c_temp++;
  21. }
  22. }
  23. //System.out.println(c_temp);
  24. int max = 0;
  25. int m = c_temp;
  26. //System.out.println(m);
  27. int[] sum = new int[m];
  28. for (int i = 0; i < m; i++) {
  29. sum[i] = Math.abs(arr[arr_temp[i]][0] - arr[arr_temp[i]][1]);
  30. if (sum[i] >= max)
  31. max = sum[i];
  32. }
  33. System.out.println();
  34. for (int i = 0; i < m; i++) {
  35. if (sum[i] == max) {
  36. System.out.println(arr[arr_temp[i]][0]+" "+arr[arr_temp[i]][1]);
  37. }
  38. }
  39. }
  40. }
Add Comment
Please, Sign In to add comment