結果
問題 | No.182 新規性の虜 |
ユーザー |
![]() |
提出日時 | 2023-04-07 10:44:14 |
言語 | Rust (1.83.0 + proconio) |
結果 |
AC
|
実行時間 | 16 ms / 5,000 ms |
コード長 | 1,117 bytes |
コンパイル時間 | 12,702 ms |
コンパイル使用メモリ | 380,328 KB |
実行使用メモリ | 5,260 KB |
最終ジャッジ日時 | 2024-10-02 18:30:10 |
合計ジャッジ時間 | 14,326 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 27 |
ソースコード
fn main() {let _n: i64 = read();let mut a: Vec<i64> = read_vec();a.sort();let g: Vec<(i64, i64)> = run_length_encoding(a);let mut res: i64 = 0;for (_, b) in g {if b == 1 {res += 1;}}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()}