complete 2056.rs 16724.rs 17143.rs 25186.rs 26545.rs 27172.rs 30524.rs
This commit is contained in:
33
storage/zeta/rs/completed/25186.rs
Normal file
33
storage/zeta/rs/completed/25186.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
use std::io::stdin;
|
||||
|
||||
fn is_happy(clothes: &Vec<u64>) -> bool {
|
||||
let sum = clothes.iter().sum::<u64>();
|
||||
if sum == 1 {
|
||||
return true;
|
||||
}
|
||||
let max = clothes.iter().max().unwrap();
|
||||
|
||||
sum >= max * 2
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let mut lines = stdin().lines();
|
||||
lines.next();
|
||||
|
||||
let clothes: Vec<u64> = lines
|
||||
.next()
|
||||
.unwrap()
|
||||
.unwrap()
|
||||
.split_ascii_whitespace()
|
||||
.map(|x| x.parse::<u64>().unwrap())
|
||||
.collect();
|
||||
|
||||
println!(
|
||||
"{}",
|
||||
if is_happy(&clothes) {
|
||||
"Happy"
|
||||
} else {
|
||||
"Unhappy"
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user