結果

問題 No.2386 Udon Coupon (Easy)
ユーザー 👑 MizarMizar
提出日時 2023-06-28 02:50:49
言語 Rust
(1.77.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 1,331 bytes
コンパイル時間 4,821 ms
コンパイル使用メモリ 166,316 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-18 00:37:51
合計ジャッジ時間 3,426 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 0 ms
4,348 KB
testcase_06 AC 1 ms
4,348 KB
testcase_07 AC 3 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 0 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 3 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 1 ms
4,348 KB
testcase_19 AC 1 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 1 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 2 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 1 ms
4,348 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 2 ms
4,348 KB
testcase_34 AC 2 ms
4,348 KB
testcase_35 AC 3 ms
4,348 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 2 ms
4,348 KB
testcase_39 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fn main() {
    let mut input = String::with_capacity(1024);
    std::io::Read::read_to_string(&mut std::io::stdin(), &mut input).unwrap();
    let mut tokens = input.split_whitespace();
    let n = tokens.next().unwrap().parse::<usize>().unwrap();
    let [a, b, c] = [
        tokens.next().unwrap().parse::<u64>().unwrap(),
        tokens.next().unwrap().parse::<u64>().unwrap(),
        tokens.next().unwrap().parse::<u64>().unwrap(),
    ];

    let mut dp = vec![0u64; n + 1];
    let mut result = 0;

    for i in 0..=n {
        match i {
            0..=2 => {}
            3..=4 => {
                result.chmax(dp[i - 3] + a);
            }
            5..=9 => {
                result.chmax(dp[i - 3] + a);
                result.chmax(dp[i - 5] + b);
            }
            _ => {
                result.chmax(dp[i - 3] + a);
                result.chmax(dp[i - 5] + b);
                result.chmax(dp[i - 10] + c);
            }
        }
        dp[i] = result;
    }

    println!("{}", result);
}

trait Change {
    fn chmax(&mut self, x: Self);
    fn chmin(&mut self, x: Self);
}
impl<T: PartialOrd> Change for T {
    fn chmax(&mut self, x: T) {
        if *self < x {
            *self = x;
        }
    }
    fn chmin(&mut self, x: T) {
        if *self > x {
            *self = x;
        }
    }
}
0