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, i));
        vb.push((b, a, i));
        // ds.push((a, b));
    }
    va.sort(); va.reverse();
    vb.sort(); vb.reverse();
    let mut flag = vec![false; n];
    let mut ans = 0;
    let mut ia = 0;
    let mut ib = 0;
    for i in 0..n {
    	while ia < va.len() && flag[va[ia].2] {
        	ia += 1;
        }
    	while ib < vb.len() && flag[vb[ib].2] {
        	ib += 1;
        }
        if ia == va.len() && ib == vb.len() {
        	break;
        }
        let ta = va[ia];
        let tb = vb[ib];
        let c = ta.0-tb.0;
        let d = tb.1-ta.1;
    	if i % 2 == 0 {
        	if c > d {
            	flag[ta.2] = true;
                ans += ta.0;
            	ia += 1;
            } else {
            	flag[tb.2] = true;
                ans += tb.1;
            	ib += 1;
            }
        } else {
        	if c < d {
            	flag[ta.2] = true;
                ans -= ta.1;
            	ia += 1;
            } else {
            	flag[tb.2] = true;
                ans -= tb.0;
            	ib += 1;
            }
        }
    }
    println!("{}", ans);
}