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 Rust (1.15.1) (judge verdict: Runtime Error)

// Try NIKKEI Programming Contest 2019
// author: Leonardone @ NEETSDKASU

fn main() {
    let mut stdin = String::new();
    std::io::Read::read_to_string(
        &mut std::io::stdin(),
        &mut stdin).unwrap();
    let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
        ($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut va = vec![];
    let mut vb = vec![];
    // let mut ds = vec![];
    let mut sum_a = 0;
    let mut sum_b = 0;
    for i in 0..n {
        let a = get!();
        let b = get!();
        sum_a += a;
        sum_b += b;
        va.push((a + b, a, b, i));
        vb.push((a + b, b, a, i));
        // ds.push((a, b));
    }
    va.sort();
    vb.sort();
    let mut flag = vec![false; n];
    let mut ans = 0;
    for _ in 0..n {
        while let Some((_, a,b,i)) = va.pop() {
	        if !flag[i] {
    	    	flag[i] = true;
        		sum_a -= a;
        		sum_b -= b;
        		ans += a;
        		break;
            }
        }
        while let Some((_, b,a,i)) = vb.pop() {
        	if !flag[i] {
            	flag[i] = true;
                sum_a -= a;
                sum_b -= b;
                ans -= b;
                break;
            }
        }
    }
    println!("{}", ans);
}