結果

問題 No.45 回転寿司
ユーザー iwkjoseciwkjosec
提出日時 2019-10-03 22:54:52
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 33 ms / 5,000 ms
コード長 585 bytes
コンパイル時間 1,117 ms
コンパイル使用メモリ 110,912 KB
実行使用メモリ 27,812 KB
最終ジャッジ日時 2024-04-14 09:44:21
合計ジャッジ時間 3,198 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
27,604 KB
testcase_01 AC 33 ms
27,336 KB
testcase_02 AC 32 ms
25,388 KB
testcase_03 AC 33 ms
27,596 KB
testcase_04 AC 32 ms
25,768 KB
testcase_05 AC 28 ms
25,124 KB
testcase_06 AC 33 ms
27,812 KB
testcase_07 AC 33 ms
25,428 KB
testcase_08 AC 32 ms
25,516 KB
testcase_09 AC 33 ms
25,776 KB
testcase_10 AC 31 ms
25,636 KB
testcase_11 AC 32 ms
25,552 KB
testcase_12 AC 33 ms
27,552 KB
testcase_13 AC 28 ms
25,216 KB
testcase_14 AC 29 ms
25,260 KB
testcase_15 AC 33 ms
27,604 KB
testcase_16 AC 32 ms
25,644 KB
testcase_17 AC 32 ms
25,892 KB
testcase_18 AC 33 ms
27,728 KB
testcase_19 AC 33 ms
27,804 KB
testcase_20 AC 28 ms
25,380 KB
testcase_21 AC 28 ms
25,256 KB
testcase_22 AC 29 ms
25,008 KB
testcase_23 AC 28 ms
25,264 KB
testcase_24 AC 28 ms
25,340 KB
testcase_25 AC 27 ms
24,880 KB
testcase_26 AC 33 ms
25,556 KB
testcase_27 AC 33 ms
25,648 KB
testcase_28 AC 32 ms
25,512 KB
testcase_29 AC 33 ms
25,896 KB
testcase_30 AC 32 ms
25,556 KB
testcase_31 AC 28 ms
25,084 KB
testcase_32 AC 29 ms
25,352 KB
testcase_33 AC 32 ms
25,768 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var n = int.Parse(ReadLine());
        var v = ReadLine().Split().Select(int.Parse).ToArray();
        var dp = new int[n, 2];
        dp[0, 0] = 0;
        dp[0, 1] = v[0];
        for (int i = 1; i < n; i++)
        {
            dp[i, 0] = Max(dp[i - 1, 0], dp[i - 1, 1]);
            dp[i, 1] = Max(dp[i - 1, 0] + v[i], dp[i - 1, 1]);
        }
        WriteLine(Max(dp[n - 1, 0], dp[n - 1, 1]));
    }
}
0