complete 2056.rs 16724.rs 17143.rs 25186.rs 26545.rs 27172.rs 30524.rs

This commit is contained in:
2025-07-05 11:59:23 +09:00
parent 77d1aa106b
commit 477c09c46a
7 changed files with 734 additions and 0 deletions

View 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"
}
)
}