結果
問題 |
No.79 過小評価ダメ・ゼッタイ
|
ユーザー |
![]() |
提出日時 | 2023-04-07 01:13:32 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 11 ms / 5,000 ms |
コード長 | 1,210 bytes |
コンパイル時間 | 15,108 ms |
コンパイル使用メモリ | 379,112 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-10-02 18:28:15 |
合計ジャッジ時間 | 15,774 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 22 |
ソースコード
fn main() { let _n: i64 = read(); let mut l: Vec<i64> = read_vec(); l.sort(); let mut g: Vec<(i64, i64)> = run_length_encoding(l); g.sort_by(|a, b| { if a.1 == b.1 { return (-a.0).partial_cmp(&(-b.0)).unwrap(); } (-a.1).partial_cmp(&(-b.1)).unwrap() }); let res: i64 = g[0].0; println!("{}", res); } #[allow(dead_code)] fn run_length_encoding<T: std::cmp::PartialEq + Copy>(x: Vec<T>) -> Vec<(T, i64)> { let mut ret: Vec<(T, i64)> = Vec::new(); let l: usize = x.len(); let mut i: usize = 0; let mut j: usize = 0; while i < l { while j < l && x[i] == x[j] { j += 1usize; } ret.push((x[i], (j-i) as i64)); i = j; } ret } #[allow(dead_code)] fn read_string() -> String { let mut s: String = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().to_string() } #[allow(dead_code)] fn read<T: std::str::FromStr>() -> T { read_string().parse().ok().unwrap() } #[allow(dead_code)] fn read_vec<T: std::str::FromStr>() -> Vec<T> { read_string() .split_whitespace() .map(|v| v.parse().ok().unwrap()) .collect() }