結果

問題 No.29 パワーアップ
ユーザー cra77756176
提出日時 2022-11-19 14:02:33
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 614 bytes
コンパイル時間 12,811 ms
コンパイル使用メモリ 400,620 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-20 14:31:51
合計ジャッジ時間 14,016 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::{self, BufRead};

fn main() {
    let input = io::stdin()
        .lock()
        .lines()
        .flat_map(|l| {
            l.unwrap()
                .split_whitespace()
                .map(|n| n.parse::<usize>().unwrap())
                .collect::<Vec<_>>()
        })
        .collect::<Vec<_>>();

    let counts = (1..=10)
        .map(|i| input[1..].iter().filter(|&&n| n == i).count())
        .collect::<Vec<_>>();

    let n_pairs = counts.iter().map(|i| i / 2).sum::<usize>();
    let n_fours = counts.iter().map(|i| i % 2).sum::<usize>() / 4;

    println!("{}", n_pairs + n_fours);
}
0