結果

問題 No.2852 Yakitori Optimization Problem
ユーザー well-definedwell-defined
提出日時 2024-09-14 17:07:02
言語 Rust
(1.77.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 610 bytes
コンパイル時間 12,692 ms
コンパイル使用メモリ 401,040 KB
実行使用メモリ 26,360 KB
最終ジャッジ日時 2024-09-14 17:07:24
合計ジャッジ時間 17,409 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
7,716 KB
testcase_01 AC 58 ms
19,308 KB
testcase_02 AC 49 ms
16,524 KB
testcase_03 AC 76 ms
25,856 KB
testcase_04 AC 64 ms
21,064 KB
testcase_05 AC 24 ms
8,980 KB
testcase_06 AC 8 ms
5,376 KB
testcase_07 AC 62 ms
20,872 KB
testcase_08 AC 6 ms
5,376 KB
testcase_09 AC 77 ms
25,452 KB
testcase_10 AC 106 ms
26,228 KB
testcase_11 AC 82 ms
26,228 KB
testcase_12 AC 81 ms
26,360 KB
testcase_13 AC 80 ms
26,360 KB
testcase_14 AC 79 ms
26,360 KB
testcase_15 AC 80 ms
26,228 KB
testcase_16 AC 82 ms
26,232 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main () {
    input! {
        n: usize,
        k: usize,
        a: [i128; n],
        b: [i128; n],
        c: [i128; n],
    }
    let mut dif = b.iter()
        .zip(c.iter())
        .enumerate()
        .map(|(i, (b, c))| {
            (b-c, i)
        })
        .collect::<Vec<_>>();
    dif.sort_by(|a, b| b.cmp(a));
    let mut ac = a.iter()
        .zip(c.iter())
        .map(|(a, c)| a+c )
        .collect::<Vec<_>>();
    for (i, v) in dif.iter().enumerate() {
        if i >= k {break;}
        ac[v.1] += v.0;
    }
    println!("{}", ac.iter().sum::<i128>());
    
}
0