結果

問題 No.3433 [Cherry 8th Tune A] ADD OIL!
コンテスト
ユーザー elphe
提出日時 2026-01-24 14:49:09
言語 Rust
(1.93.0 + proconio + num + itertools)
結果
AC  
実行時間 1 ms / 2,000 ms
コード長 1,092 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,100 ms
コンパイル使用メモリ 205,720 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2026-01-24 14:50:00
合計ジャッジ時間 3,012 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

fn main() {
    let stdin = std::io::read_to_string(std::io::stdin()).unwrap();
    let mut stdin = stdin.split_whitespace();

    let t: usize = stdin.next().unwrap().parse().unwrap();
    let testcases = (0..t)
        .map(|_| {
            let n: usize = stdin.next().unwrap().parse().unwrap();
            let k: u32 = stdin.next().unwrap().parse().unwrap();
            let a: Vec<u32> = (0..n)
                .map(|_| stdin.next().unwrap().parse().unwrap())
                .collect();
            (k, a)
        })
        .collect::<Vec<_>>();

    println!("{}", output(solve(testcases)));
}

fn solve(testcases: Vec<(u32, Vec<u32>)>) -> Vec<u64> {
    testcases
        .into_iter()
        .map(|(k, mut a)| {
            let min_a = *a.iter().min().unwrap();
            let pos = a.iter().position(|&a| a == min_a).unwrap();
            a[pos] -= k;
            a.into_iter().map(|a| a as u64).product()
        })
        .collect()
}

fn output(ans: Vec<u64>) -> String {
    ans.into_iter()
        .map(|x| x.to_string())
        .collect::<Vec<_>>()
        .join("\n")
}
0