結果

問題 No.1390 Get together
コンテスト
ユーザー tonyu0
提出日時 2021-02-12 22:29:45
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 989 bytes
コンパイル時間 18,711 ms
コンパイル使用メモリ 377,648 KB
実行使用メモリ 15,232 KB
最終ジャッジ日時 2024-07-19 23:05:12
合計ジャッジ時間 17,573 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 15 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let n: usize = itr.next().unwrap().parse().unwrap();
    let _: usize = itr.next().unwrap().parse().unwrap();
    let mut col: Vec<Vec<usize>> = vec![vec![]; n];
    for _ in 0..n {
        let b = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        let c = itr.next().unwrap().parse::<usize>().unwrap() - 1;
        col[c].push(b);
    }

    let mut ans = 0;
    for i in 0..n {
        if col[i].len() == 0 {
            continue;
        }
        col[i].sort();
        let mut j = 0;
        let l = col[i].len();
        let mut v = Vec::new();
        while j < l {
            let mut k = 1;
            while j + k < l && col[i][j + k] == col[i][j] {
                k += 1;
            }
            v.push(k);
            j += k;
        }
        ans += v.len() - 1;
    }
    println!("{}", ans);
}
0