19 lines
495 B
Rust
19 lines
495 B
Rust
|
use std::{cmp::Reverse, io::stdin};
|
||
|
|
||
|
fn main() {
|
||
|
let lines: Vec<_> = stdin().lines().map(Result::unwrap).collect();
|
||
|
let mut elves: Vec<_> = lines
|
||
|
.split(|s| s.is_empty())
|
||
|
.map(|entries| {
|
||
|
entries
|
||
|
.iter()
|
||
|
.map(|c| c.parse::<u64>().unwrap())
|
||
|
.sum::<u64>()
|
||
|
})
|
||
|
.collect();
|
||
|
elves.sort_by_key(|&s| Reverse(s));
|
||
|
|
||
|
println!("{}", elves[0]);
|
||
|
println!("{}", &elves[..3].iter().sum::<u64>());
|
||
|
}
|