結果

問題 No.2730 Two Types Luggage
ユーザー かもめのうで
提出日時 2024-04-20 00:57:58
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 252 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 13,055 ms
コンパイル使用メモリ 396,988 KB
実行使用メモリ 29,352 KB
最終ジャッジ日時 2024-10-11 19:45:51
合計ジャッジ時間 19,843 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 35
権限があれば一括ダウンロードができます

ソースコード

diff #

#![allow(unused)]
use proconio::*;
use std::collections::*;

fn main() {
    input! {
        n: usize, m: usize, w: usize,
        mut a: [usize; n],
        b: [usize; m],
        c: [usize; m]
    }
    a.sort_by(|a, b| b.cmp(a));
    let mut rui = vec![0];
    for ai in a {
        rui.push(rui[rui.len()-1]+ai)
    }

    let mut ans = 0;
    for bit in 0..1<<m {
        let mut val_cnt = 0;
        let mut weight_cnt = 0;
        for i in 0..m {
            if bit&1<<i > 0 {
                val_cnt += c[i];
                weight_cnt += b[i];
            }
        }
        if weight_cnt > w {
            continue;
        }
        val_cnt += rui[(w-weight_cnt).min(n)];
        ans = ans.max(val_cnt)
    }
    println!("{ans}")
}
0