fork download
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. long l1 = scanner.nextLong();
  8. long r1 = scanner.nextLong();
  9. long l2 = scanner.nextLong();
  10. long r2 = scanner.nextLong();
  11. scanner.close();
  12.  
  13. long left = Math.max(l1, l2);
  14. long right = Math.min(r1, r2);
  15.  
  16. if (left <= right) {
  17. System.out.println(left + " " + right);
  18. } else {
  19. System.out.println(-1);
  20. }
  21. }
  22. }
  23.  
Success #stdin #stdout 0.18s 56280KB
stdin
324
764
867
234
stdout
-1