結果
| 問題 | 
                            No.45 回転寿司
                             | 
                    
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-06-09 10:19:45 | 
| 言語 | Rust  (1.83.0 + proconio)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 698 bytes | 
| コンパイル時間 | 11,458 ms | 
| コンパイル使用メモリ | 383,592 KB | 
| 実行使用メモリ | 6,948 KB | 
| 最終ジャッジ日時 | 2024-09-21 05:28:14 | 
| 合計ジャッジ時間 | 12,578 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 29 WA * 1 | 
ソースコード
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);
    }
    
    if n==1{
        println!("{}",v[0]);
        std::process::exit(0);
    }
    let mut dp=vec![INF;n];
    dp[0]=v[0];
    dp[1]=v[1];
    for i in 2..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]);
}