Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Collections;
- import java.util.List;
- import java.util.Scanner;
- public class Contest27393 {
- public static void main(String[] args) {
- new Contest27393().problemF();
- }
- private Scanner scanner;
- public void problemF() {
- scanner = new Scanner(System.in);
- int a1 = scanner.nextInt();
- int b1 = scanner.nextInt();
- int a2 = scanner.nextInt();
- int b2 = scanner.nextInt();
- List<Pair> pairs = new ArrayList<>(List.of(
- new Pair(Math.max(a1, a2), b1 + b2),
- new Pair(Math.max(a2, b1), a1 + b2),
- new Pair(Math.max(a1, b2), a2 + b1),
- new Pair(Math.max(b1, b2), a1 + a2)
- ));
- Collections.sort(pairs);
- Pair pair = pairs.get(0);
- System.out.println(pair.getA() + " " + pair.getB());
- }
- private static class Pair implements Comparable<Pair> {
- private final int a;
- private final int b;
- public Pair(int a, int b) {
- this.a = a;
- this.b = b;
- }
- public int getA() {
- return a;
- }
- public int getB() {
- return b;
- }
- @Override
- public int compareTo(Pair pair) {
- return Integer.compare(this.getA() * this.getB(), pair.getA() * pair.getB());
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement