結果

問題 No.45 回転寿司
ユーザー nanae
提出日時 2017-03-02 19:57:32
言語 D
(dmd 2.109.1)
結果
AC  
実行時間 1 ms / 5,000 ms
コード長 406 bytes
コンパイル時間 1,219 ms
コンパイル使用メモリ 119,636 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-12 07:10:17
合計ジャッジ時間 2,125 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio;
import std.string, std.conv, std.array, std.algorithm;
import std.uni, std.math, std.container;
import core.bitop, std.datetime;

void main(){
    int N = readln.chomp.to!int;
    auto V = readln.split.to!(int[]);
    int[] dp = new int[](N + 1);

    dp[0] = 0, dp[1] = V[0];
    foreach(i ; 2 .. N + 1){
        dp[i] = max(dp[i - 1], dp[i - 2] + V[i - 1]);
    }

    writeln(dp[N]);
}
0