結果

問題 No.45 回転寿司
ユーザー rhoo
提出日時 2022-06-09 10:20:49
言語 Rust
(1.83.0 + proconio)
結果
WA  
実行時間 -
コード長 598 bytes
コンパイル時間 12,839 ms
コンパイル使用メモリ 382,416 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-21 05:28:30
合計ジャッジ時間 14,270 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2 WA * 2
other AC * 24 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

use std::io::Read;

const INF:usize=usize::MAX>>2;

fn main(){
    let mut input = "".to_owned();
    std::io::stdin().read_to_string(&mut input).unwrap();
    let mut input = input.split_ascii_whitespace();
    macro_rules! read(($ty:ty) => (input.next().unwrap().parse::<$ty>().unwrap()));

    let n=read!(usize);
    let mut v=vec![!0;n];

    for i in 0..n{
        v[i]=read!(usize);
    }

    let mut dp=vec![INF;n];
    dp[0]=v[0];

    for i in 1..n{
        dp[i]=dp[i-1];
        for j in 0..i-1{
            dp[i]=dp[i].max(dp[j]+v[i]);
        }
    }

    println!("{}",dp[n-1]);
}

0