結果

問題 No.2852 Yakitori Optimization Problem
ユーザー NakLon131NakLon131
提出日時 2024-08-25 13:54:17
言語 Rust
(1.77.0)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 976 bytes
コンパイル時間 12,891 ms
コンパイル使用メモリ 403,800 KB
実行使用メモリ 16,880 KB
最終ジャッジ日時 2024-08-25 13:54:32
合計ジャッジ時間 13,950 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
6,812 KB
testcase_01 AC 48 ms
12,544 KB
testcase_02 AC 39 ms
10,624 KB
testcase_03 AC 67 ms
16,396 KB
testcase_04 AC 53 ms
13,696 KB
testcase_05 AC 19 ms
6,944 KB
testcase_06 AC 7 ms
6,940 KB
testcase_07 AC 52 ms
13,568 KB
testcase_08 AC 5 ms
6,944 KB
testcase_09 AC 69 ms
16,276 KB
testcase_10 AC 71 ms
16,868 KB
testcase_11 AC 72 ms
16,768 KB
testcase_12 AC 71 ms
16,880 KB
testcase_13 AC 69 ms
16,768 KB
testcase_14 AC 69 ms
16,780 KB
testcase_15 AC 69 ms
16,768 KB
testcase_16 AC 69 ms
16,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    input!{
		n: usize, k: usize,
		a: [i64; n],
		b: [i64; n],
		c: [i64; n],
	}

	let mut prefer_b = vec![(0, 0); n];
	for i in 0..n {
		prefer_b[i] = (b[i]-c[i], i);
	}
	prefer_b.sort();
	prefer_b.reverse();

	let mut ans = 0;
	for i in 0..n {
		let pos = prefer_b[i].1;
		if i < k {
			ans += a[pos] + b[pos];
		}
		else {
			ans += a[pos] + c[pos];
		}
	}
	println!("{}", ans);
}

// const MOD17: usize = 1000000007;
// const MOD93: usize = 998244353;
// const INF: usize = 1 << 60;
// let dx = vec![!0, 0, 1, 0]; // 上左下右
// let dy = vec![0, !0, 0, 1]; // 上左下右
// let d = vec!{(!0, 0), (0, !0), (1, 0), (0, 1)}; // 上左下右

#[allow(unused)]
use proconio::{input, marker::Chars, marker::Usize1};

#[allow(unused)]
use std::{
	mem::swap,
	cmp::min, cmp::max,
	cmp::Reverse,
	collections::HashSet, collections::BTreeSet,
	collections::HashMap, collections::BTreeMap,
	collections::BinaryHeap,
	collections::VecDeque,
	iter::FromIterator,
};
0