AtCoder Beginner Contest 238 B

https://atcoder.jp/contests/abc238/tasks/abc238_b

ソートして差を取るだけですが、最後に360を付ける必要がありますね。

// Pizza
#![allow(non_snake_case)]

fn read<T: std::str::FromStr>() -> T {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    line.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
            .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let N: usize = read();
    let A: Vec<i32> = read_vec();
    let mut B = Vec::<i32>::new();
    B.push(0);
    for (i, a) in A.iter().enumerate() {
        B.push((B[i] + a) % 360)
    }
    B.push(360);
    B.sort();
    let max_angle = (0..(N+1)).map(|i| B[i+1] - B[i]).max();
    println!("{}", max_angle.unwrap())
}