Module c

Expand description

ยงABC 352 C - Standing On The Shoulders

refs: https://atcoder.jp/contests/abc352/tasks/abc352_c

use proconio::input;

fn main() {
    input! {
        n: usize,
        giants: [(usize, usize); n],
    }

    let mx = giants
        .iter()
        .map(|(a, b)| *b - *a)
        .max()
        .expect("Cannot be empty");
    let sm = giants.iter().map(|(a, _)| *a).sum::<usize>();

    println!("{}", mx + sm);
}