Ansaid

123

Jan 24th, 2021 (edited)
313
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. public class Main
  2. {
  3.  
  4. class Point {
  5. int x;
  6. int y;
  7. }
  8.  
  9. public static void main(String[] args) {
  10.  
  11. int n;
  12. Scanner in = new Scanner(System.in);
  13. n = in.nextInt();
  14.  
  15. ArrayList<Point> points = new ArrayList();
  16. for (int i = 0; i < n; i++) {
  17. x = in.nextInt();
  18. y = in.nextInt();
  19. Point point = new Point();
  20. point.x = x;
  21. point.y = y;
  22. points.add(point);
  23. }
  24.  
  25. Point result = new Point();
  26. int maxY = -10000000;
  27. if (n % 2 == 0) {
  28. for (int i = 0; i < points.size(); i++) {
  29. if (points.y > maxY) {
  30. result = points.get(i);
  31. }
  32. }
  33. double otvet;
  34. for (int i = 0; i < points.size(); i++) {
  35. if (result.y = maxY) {
  36. if (points.get(i).x < result.x) {
  37. otvet = points.get(i).x + (result.x - points.get(i).x) / 2;
  38. } else {
  39. otvet = result.x + (points.get(i).x - result.x) / 2;
  40. }
  41. System.out.print(otvet);
  42. }
  43. }
  44. } else {
  45. maxY = -10000000;
  46. for (int i = 0; i < points.size(); i++) {
  47. if (points.get(i).y > maxY) {
  48. result = points.get(i);
  49. }
  50. }
  51. System.out.print(result.x);
  52. }
  53.  
  54. }
  55. }
  56.  
Add Comment
Please, Sign In to add comment