use std::collections::*; fn main(){ let mut sc = Scanner::new(); while let Ok(n) = sc.next() { let mut cnt: HashMap = HashMap::new(); for _ in 0..n { let s = sc.ns(); match cnt.get(&s).cloned() { Some(k) => cnt.insert(s, k+1), _ => cnt.insert(s, 1), }; }; let mut max = 0; for (_, val) in cnt.iter() { if &max < val { max = val.clone(); } } println!("{}", if max <= (n+1)/2 { "YES" } else { "NO" }); } } #[allow(dead_code)] struct Scanner { token_buffer : Vec, index : usize, } #[allow(dead_code)] impl Scanner { fn new() -> Scanner{ Scanner { token_buffer: vec![], index: 0 } } fn next(& mut self) -> Result where T: std::str::FromStr { let s = try!(self.fetch_token()); let t = try!(s.parse::().map_err(|_| "Parse error")); Ok(t) } fn ni(& mut self) -> i32 { self.next::().unwrap() } fn nf(& mut self) -> f64 { self.next::().unwrap() } fn ns(& mut self) -> String { self.next::().unwrap() } fn fetch_token(&mut self) -> Result<&String,&str> { while self.index >= self.token_buffer.len() { let mut st = String::new(); while st.trim() == "" { match std::io::stdin().read_line(&mut st) { Ok(l) if l > 0 => continue, Ok(_) => return Err("End of file"), Err(_) => return Err("Failed to read line"), } } self.token_buffer = st.split_whitespace() .map(|x| x.to_string()) .collect(); self.index = 0; } self.index += 1; Ok(&self.token_buffer[self.index - 1]) } }