結果

問題 No.3288 Sloppy Land Grading
ユーザー atcoder8
提出日時 2025-10-03 22:14:10
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 39 ms / 2,000 ms
コード長 720 bytes
コンパイル時間 10,590 ms
コンパイル使用メモリ 402,508 KB
実行使用メモリ 11,904 KB
最終ジャッジ日時 2025-10-03 22:14:27
合計ジャッジ時間 12,645 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main() {
    input! {
        t: usize,
    }

    let output = (0..t)
        .map(|_| solve())
        .map(|cost| cost.to_string())
        .collect::<Vec<String>>()
        .join("\n");
    println!("{output}");
}

fn solve() -> usize {
    input! {
        (a, b, c, x, y, z): (usize, usize, usize, usize, usize, usize),
    }

    let mut nodes = [(a, x), (b, y), (c, z)];
    nodes.sort_unstable_by_key(|&(value, _)| value);

    let calc_cost = |pivot: usize| {
        let pivot_value = nodes[pivot].0;
        nodes
            .iter()
            .map(|&(value, cost)| pivot_value.abs_diff(value) * cost)
            .sum::<usize>()
    };

    (0..3).map(calc_cost).min().unwrap()
}
0