Problem:
Score : 100 points

Problem Statement

We conducted a survey on newspaper subscriptions.
More specifically, we asked each of the N respondents the following two questions:

Question 1: Are you subscribing to Newspaper X?

Question 2: Are you subscribing to Newspaper Y?

As the result, A respondents answered "yes" to Question 1, and B respondents answered "yes" to Question 2.

What are the maximum possible number and the minimum possible number of respondents subscribing to both newspapers X and Y?

Write a program to answer this question.

Constraints

1 \leq N \leq 100

0 \leq A \leq N

0 \leq B \leq N

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N A B

Output

Print the maximum possible number and the minimum possible number of respondents subscribing to both newspapers, in this order, with a space in between.

Sample Input 1

10 3 5

Sample Output 1

3 0

In this sample, out of the 10 respondents, 3 answered they are subscribing to Newspaper X, and 5 answered they are subscribing to Newspaper Y.

Here, the number of respondents subscribing to both newspapers is at most 3 and at least 0.

Sample Input 2

10 7 5

Sample Output 2

5 2

In this sample, out of the 10 respondents, 7 answered they are subscribing to Newspaper X, and 5 answered they are subscribing to Newspaper Y.

Here, the number of respondents subscribing to both newspapers is at most 5 and at least 2.

Sample Input 3

100 100 100

Sample Output 3

100 100

Solution in Java8 (OpenJDK 1.8.0) (judge verdict: Runtime Error)

import java.util.*;

public class Main {

	private static int max = 0;
	private static int count = 0;
	static Stack<Integer> list = new Stack<Integer>();

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int m = scan.nextInt();
		int[][] arr01 = new int[n + 1][n + 1];
		for (int i = 1; i <= n + m - 1; i++) {
			arr01[scan.nextInt()][scan.nextInt()] = 1;
		}
		int[][] ans = new int[n + 1][n + 1];
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= n; j++) {
				if (arr01[j][i] != 0) {
					ans[j][i] = max(arr01, i, j);
					max = 0;
					count = 0;
				}
			}
		}
		for (int i = 1; i <= n; i++) {
			System.out.println(maxPath(ans, i));
		}
		scan.close();
	}

	private static int max(int[][] arr01, int col, int row) {

		count++;
		list.add(row);
		for (int i = 1; i < arr01.length; i++) {
			if (arr01[i][row] != 0) {
				max(arr01, row, i);
			}
		}

		if (count > max) {
			max = count;
		}
		count--;
		if (!list.isEmpty()) {
			list.pop();
		}
		return max;

	}

	private static int maxPath(int ans[][], int col) {
		int max = 0;
		int ret = 0;
		for (int i = 1; i < ans.length; i++) {
			if (ans[i][col] > max) {
				max = ans[i][col];
				ret = i;
			}
		}
		return ret;
	}
}