結果

問題 No.2390 Udon Coupon (Hard)
ユーザー koba-e964koba-e964
提出日時 2023-07-23 10:54:02
言語 Rust
(1.77.0)
結果
WA  
実行時間 -
コード長 1,565 bytes
コンパイル時間 6,084 ms
コンパイル使用メモリ 178,180 KB
実行使用メモリ 64,236 KB
最終ジャッジ日時 2023-10-24 17:28:59
合計ジャッジ時間 11,938 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
64,236 KB
testcase_01 AC 49 ms
64,236 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 51 ms
64,236 KB
testcase_06 AC 52 ms
64,236 KB
testcase_07 AC 52 ms
64,236 KB
testcase_08 AC 50 ms
64,236 KB
testcase_09 AC 49 ms
64,236 KB
testcase_10 AC 50 ms
64,236 KB
testcase_11 AC 49 ms
64,236 KB
testcase_12 AC 50 ms
64,236 KB
testcase_13 AC 52 ms
64,236 KB
testcase_14 AC 52 ms
64,236 KB
testcase_15 AC 51 ms
64,236 KB
testcase_16 AC 52 ms
64,236 KB
testcase_17 AC 52 ms
64,236 KB
testcase_18 AC 49 ms
64,236 KB
testcase_19 AC 51 ms
64,236 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 53 ms
64,236 KB
testcase_40 WA -
testcase_41 AC 51 ms
64,236 KB
testcase_42 AC 50 ms
64,236 KB
testcase_43 AC 50 ms
64,236 KB
testcase_44 AC 52 ms
64,236 KB
testcase_45 AC 51 ms
64,236 KB
testcase_46 WA -
testcase_47 AC 50 ms
64,236 KB
testcase_48 AC 50 ms
64,236 KB
testcase_49 AC 50 ms
64,236 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes.by_ref().map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr,) => {};
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => { ($(read_value!($next, $t)),*) };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

fn main() {
    input! {
        n: i64,
        ab: [(usize, i64); 3],
    }
    const W: usize = 8_000_000;
    let mut dp = vec![0i64; W];
    for i in 1..W {
        let mut me = dp[i - 1];
        for &(a, b) in &ab {
            if i >= a {
                me = std::cmp::max(me, dp[i - a] + b);
            }
        }
        dp[i] = me;
    }
    let mut ans = 0;
    for &(a, b) in &ab {
        let q = n / a as i64;
        let r = n - a as i64 * q;
        ans = std::cmp::max(ans, dp[r as usize] + q * b);
    }
    println!("{}", ans);
}
0