Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int n = rw.nextInt();
- int m = rw.nextInt();
- Pair<Integer, Integer>[] a = new Pair[n];
- Pair<Integer, Integer>[] b = new Pair[m];
- for (int i = 0; i < n; ++i)
- a[i] = new Pair<>(rw.nextInt(), rw.nextInt());
- for (int i = 0; i < m; ++i)
- b[i] = new Pair<>(rw.nextInt(), rw.nextInt());
- Arrays.sort(a, (o1, o2) -> Integer.compare(o1.getKey(), o2.getKey()));
- Arrays.sort(b, (o1, o2) -> Integer.compare(o1.getKey(), o2.getKey()));
- int ans = 0;
- if (n == 2) {
- if (a[1].getValue() - a[0].getKey() <= 720 || 1440 - a[1].getKey() + a[0].getValue() <= 720) {
- ans = 2;
- } else {
- ans = 4;
- }
- } else if (m == 2) {
- if (b[1].getValue() - b[0].getKey() <= 720 || 1440 - b[1].getKey() + b[0].getValue() <= 720) {
- ans = 2;
- } else {
- ans = 4;
- }
- } else if (n + m == 2) {
- ans = 2;
- } else if (n == 1) {
- ans = 2;
- } else if (m == 1) {
- ans = 2;
- }
- rw.println("Case #" + t_id + ": " + ans);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement