Advertisement
Guest User

Untitled

a guest
Apr 30th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. int n = rw.nextInt();
  2. int m = rw.nextInt();
  3. Pair<Integer, Integer>[] a = new Pair[n];
  4. Pair<Integer, Integer>[] b = new Pair[m];
  5.  
  6. for (int i = 0; i < n; ++i)
  7. a[i] = new Pair<>(rw.nextInt(), rw.nextInt());
  8. for (int i = 0; i < m; ++i)
  9. b[i] = new Pair<>(rw.nextInt(), rw.nextInt());
  10. Arrays.sort(a, (o1, o2) -> Integer.compare(o1.getKey(), o2.getKey()));
  11. Arrays.sort(b, (o1, o2) -> Integer.compare(o1.getKey(), o2.getKey()));
  12. int ans = 0;
  13. if (n == 2) {
  14. if (a[1].getValue() - a[0].getKey() <= 720 || 1440 - a[1].getKey() + a[0].getValue() <= 720) {
  15. ans = 2;
  16. } else {
  17. ans = 4;
  18. }
  19. } else if (m == 2) {
  20. if (b[1].getValue() - b[0].getKey() <= 720 || 1440 - b[1].getKey() + b[0].getValue() <= 720) {
  21. ans = 2;
  22. } else {
  23. ans = 4;
  24. }
  25. } else if (n + m == 2) {
  26. ans = 2;
  27. } else if (n == 1) {
  28. ans = 2;
  29. } else if (m == 1) {
  30. ans = 2;
  31. }
  32. rw.println("Case #" + t_id + ": " + ans);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement