結果

問題 No.1541 ゅゅさんのテスト勉強
ユーザー akakimidoriakakimidori
提出日時 2021-06-06 18:59:11
言語 Rust
(1.77.0)
結果
RE  
実行時間 -
コード長 2,194 bytes
コンパイル時間 11,328 ms
コンパイル使用メモリ 379,116 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-02 13:51:04
合計ジャッジ時間 12,626 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,248 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 0 ms
5,376 KB
testcase_06 AC 1 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 RE -
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 0 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 3 ms
5,376 KB
testcase_14 AC 1 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 5 ms
5,376 KB
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
warning: unused variable: `out`
  --> src/main.rs:42:45
   |
42 | fn run<W: Write>(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<W>) {
   |                                             ^^^ help: if this is intentional, prefix it with an underscore: `_out`
   |
   = note: `#[warn(unused_variables)]` on by default

ソースコード

diff #

// ---------- begin scannner ----------
#[allow(dead_code)]
mod scanner {
    use std::str::FromStr;
    pub struct Scanner<'a> {
        it: std::str::SplitWhitespace<'a>,
    }
    impl<'a> Scanner<'a> {
        pub fn new(s: &'a String) -> Scanner<'a> {
            Scanner {
                it: s.split_whitespace(),
            }
        }
        pub fn next<T: FromStr>(&mut self) -> T {
            self.it.next().unwrap().parse::<T>().ok().unwrap()
        }
        pub fn next_bytes(&mut self) -> Vec<u8> {
            self.it.next().unwrap().bytes().collect()
        }
        pub fn next_chars(&mut self) -> Vec<char> {
            self.it.next().unwrap().chars().collect()
        }
        pub fn next_vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
            (0..len).map(|_| self.next()).collect()
        }
    }
}
// ---------- end scannner ----------

use std::io::Write;

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut sc = scanner::Scanner::new(&s);
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    run(&mut sc, &mut out);
}

fn run<W: Write>(sc: &mut scanner::Scanner, out: &mut std::io::BufWriter<W>) {
    let n: usize = sc.next();
    let m: i64 = sc.next();
    let mut info = vec![];
    for _ in 0..n {
        let k: usize = sc.next();
        let c: i64 = sc.next();
        let mut a = vec![0usize; k];
        let mut b = vec![0i64; k];
        for a in a.iter_mut() {
            *a = sc.next();
            *a -= 1;
        }
        for a in b.iter_mut() {
            *a = sc.next();
        }
        info.push((c, a, b));
    }
    assert!(n <= 20);
    let mut ans = 0;
    for i in 1..(1 << n) {
        let mut s = 0;
        for (j, info) in info.iter().enumerate() {
            if i >> j & 1 == 1 {
                s += m;
                s -= info.0;
                for (a, b) in info.1.iter().zip(info.2.iter()) {
                    if i >> *a & 1 == 1 {
                        s += *b;
                    }
                }
            }
        }
        ans = ans.max(s);
    }
    println!("{}", ans);
}
0