結果

問題 No.3302 Sense Battle
ユーザー EvbCFfp1XB
提出日時 2025-10-05 22:46:51
言語 Rust
(1.83.0 + proconio)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 549 bytes
コンパイル時間 29,208 ms
コンパイル使用メモリ 404,088 KB
実行使用メモリ 197,760 KB
最終ジャッジ日時 2025-10-05 22:47:24
合計ジャッジ時間 16,950 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

use proconio::input;

fn main() {
    input! {
        n: usize,
        ab: [(i64,i64); n],
    }

    let mut dp = vec![vec![-1; n + 1]; n + 1];
    dp[n][0] = 0;
    for i in (1..=n).rev() {
        for count in 0..n {
            if dp[i][count] < 0 {
                continue;
            }
            dp[i - 1][count + 1] = dp[i - 1][count + 1].max(dp[i][count] + ab[i - 1].1);
            dp[i - 1][count] = dp[i - 1][count].max(dp[i][count] + count as i64 * ab[i - 1].0);
        }
    }

    println!("{}", dp[0].iter().max().unwrap());
}
0