1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#[macro_export]
macro_rules! mvec {
    ($val:expr) => {
        $val
    };
    ($size:expr; $($rest:expr);+) => {
        vec![mvec!($($rest);+);$size]
    };
}

#[macro_export]
macro_rules! max {
    ($e:expr) => { $e };
    ($e:expr, $($rest:expr),*) => {
        $e.max(max!($($rest),*))
    }
}

#[macro_export]
macro_rules! chmax {
    ($a:expr, $($b:expr),*) => {
        {
            let tmp = $crate::max!($($b),*);
            if $a < tmp {
                $a = tmp;
                true
            } else { false }
        }
    }
}

#[macro_export]
macro_rules! min {
    ($e:expr) => { $e };
    ($e:expr, $($rest:expr),*) => {
        $e.min(min!($($rest),*))
    }
}

#[macro_export]
macro_rules! chmin {
    ($a:expr, $($b:expr),*) => {
        {
            let tmp = $crate::min!($($b),*);
            if $a > tmp {
                $a = tmp;
                true
            } else { false }
        }
    }
}

pub use qitoy_utils_bound::{LowerBound, UpperBound};

#[cfg(test)]
mod tests {
    use super::*;

    #[test]
    fn max() {
        assert_eq!(max!(3), 3);
        assert_eq!(max!(3, -3, 4), 4);
        assert_eq!(max!(2 + 1, 4), 4);
    }

    #[test]
    fn min() {
        assert_eq!(min!(3), 3);
        assert_eq!(min!(3, -3, 4), -3);
    }
}