2022-12-01 20:41:22 +01:00
|
|
|
use std::{
|
|
|
|
cmp::Reverse,
|
|
|
|
io::{stdin, Read},
|
|
|
|
};
|
2022-12-01 19:02:20 +01:00
|
|
|
|
|
|
|
fn main() {
|
2022-12-01 20:41:22 +01:00
|
|
|
let mut data = String::new();
|
|
|
|
stdin().read_to_string(&mut data).unwrap();
|
|
|
|
|
|
|
|
let lines: Vec<_> = data.lines().collect();
|
2022-12-01 19:02:20 +01:00
|
|
|
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>());
|
|
|
|
}
|