Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Main
- {
- class Point {
- int x;
- int y;
- }
- public static void main(String[] args) {
- int n;
- Scanner in = new Scanner(System.in);
- n = in.nextInt();
- ArrayList<Point> points = new ArrayList();
- for (int i = 0; i < n; i++) {
- x = in.nextInt();
- y = in.nextInt();
- Point point = new Point();
- point.x = x;
- point.y = y;
- points.add(point);
- }
- Point result = new Point();
- int maxY = -10000000;
- if (n % 2 == 0) {
- for (int i = 0; i < points.size(); i++) {
- if (points.y > maxY) {
- result = points.get(i);
- }
- }
- double otvet;
- for (int i = 0; i < points.size(); i++) {
- if (result.y = maxY) {
- if (points.get(i).x < result.x) {
- otvet = points.get(i).x + (result.x - points.get(i).x) / 2;
- } else {
- otvet = result.x + (points.get(i).x - result.x) / 2;
- }
- System.out.print(otvet);
- }
- }
- } else {
- maxY = -10000000;
- for (int i = 0; i < points.size(); i++) {
- if (points.get(i).y > maxY) {
- result = points.get(i);
- }
- }
- System.out.print(result.x);
- }
- }
- }
Add Comment
Please, Sign In to add comment