結果

問題 No.3288 Sloppy Land Grading
コンテスト
ユーザー atcoder8
提出日時 2025-10-03 22:14:10
言語 Rust
(1.94.0 + proconio + num + itertools)
コンパイル:
/usr/bin/rustc_custom
実行:
./target/release/main
結果
AC  
実行時間 30 ms / 2,000 ms
+ 934µs
コード長 720 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 13,348 ms
コンパイル使用メモリ 188,896 KB
実行使用メモリ 8,448 KB
最終ジャッジ日時 2026-07-15 09:49:26
合計ジャッジ時間 13,175 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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