結果
| 問題 |
No.2730 Two Types Luggage
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-19 21:37:17 |
| 言語 | Rust (1.83.0 + proconio) |
| 結果 |
AC
|
| 実行時間 | 259 ms / 2,000 ms |
| コード長 | 1,200 bytes |
| コンパイル時間 | 17,303 ms |
| コンパイル使用メモリ | 379,504 KB |
| 実行使用メモリ | 19,456 KB |
| 最終ジャッジ日時 | 2024-10-11 14:21:22 |
| 合計ジャッジ時間 | 23,369 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 35 |
ソースコード
#![allow(dead_code, unused_imports, unused_macros, non_snake_case)]
fn main() {
let [N, M, W] = read_words::<usize>()[..] else { return };
let mut A = read_words::<usize>();
A.sort();
A.push(0);
A.reverse();
for i in 0 .. N {
A[i + 1] += A[i];
}
let B = read_words::<usize>();
let C = read_words::<usize>();
let mut ans = 0;
for bits in 0 .. 1 << M {
let mut value_sum = 0;
let mut weight_sum = 0;
for j in 0 .. M {
if bits & 1 << j != 0 {
weight_sum += B[j];
value_sum += C[j];
}
}
if weight_sum > W {
continue;
}
value_sum += A[N.min(W - weight_sum)];
ans = ans.max(value_sum);
}
println!("{ans}");
}
type Int = i64;
const MOD: Int = 1_000_000_007;
const INF: Int = 1_000_000_000;
const YESNO: [&'static str; 2] = ["Yes", "No"];
fn read_line() -> String { let mut buf = String::new(); std::io::stdin().read_line(&mut buf).ok(); buf }
fn read_words<T: std::str::FromStr>() -> Vec<T> where T::Err: std::fmt::Debug { read_line().split_whitespace().map(|x| T::from_str(x).unwrap() ).collect() }
fn yes() { println!("{}", YESNO[0]); }
fn no() { println!("{}", YESNO[1]); }
fn yesno(c: bool) { println!("{}", if c { YESNO[0] } else { YESNO[1] }); }