結果

問題 No.45 回転寿司
ユーザー skewesskewes
提出日時 2015-12-29 15:59:29
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 68 ms / 5,000 ms
コード長 675 bytes
コンパイル時間 3,130 ms
コンパイル使用メモリ 105,620 KB
実行使用メモリ 23,020 KB
最終ジャッジ日時 2023-08-27 14:30:39
合計ジャッジ時間 6,616 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
22,924 KB
testcase_01 AC 67 ms
23,020 KB
testcase_02 AC 65 ms
20,888 KB
testcase_03 AC 65 ms
22,816 KB
testcase_04 AC 65 ms
20,892 KB
testcase_05 AC 58 ms
20,748 KB
testcase_06 AC 65 ms
20,872 KB
testcase_07 AC 65 ms
20,800 KB
testcase_08 AC 66 ms
20,876 KB
testcase_09 AC 65 ms
20,784 KB
testcase_10 AC 66 ms
18,816 KB
testcase_11 AC 65 ms
20,832 KB
testcase_12 AC 66 ms
20,840 KB
testcase_13 AC 58 ms
22,812 KB
testcase_14 AC 59 ms
20,880 KB
testcase_15 AC 67 ms
20,960 KB
testcase_16 AC 66 ms
22,832 KB
testcase_17 AC 66 ms
20,864 KB
testcase_18 AC 65 ms
20,972 KB
testcase_19 AC 67 ms
20,896 KB
testcase_20 AC 57 ms
20,796 KB
testcase_21 AC 58 ms
22,820 KB
testcase_22 AC 58 ms
20,660 KB
testcase_23 AC 57 ms
20,772 KB
testcase_24 AC 57 ms
22,816 KB
testcase_25 AC 57 ms
20,676 KB
testcase_26 AC 63 ms
20,768 KB
testcase_27 AC 66 ms
20,764 KB
testcase_28 AC 66 ms
20,892 KB
testcase_29 AC 65 ms
20,780 KB
testcase_30 AC 65 ms
20,788 KB
testcase_31 AC 57 ms
20,776 KB
testcase_32 AC 58 ms
20,688 KB
testcase_33 AC 68 ms
20,928 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace yukicoder
{
    class _045
    {
        static void Main()
        {
            int n = int.Parse(Console.ReadLine());
            int[] vn = Array.ConvertAll(Console.ReadLine().Split(' ')
                , x => int.Parse(x));

            int[] dp = new int[n];
            dp[0] = vn[0];
            if(n == 1)
            {
                Console.WriteLine(dp[n - 1]);
                return;
            }

            dp[1] = Math.Max(dp[0], vn[1]);
            for (int i = 2; i < n; i++)
            {
                dp[i] = Math.Max(dp[i - 1], dp[i - 2] + vn[i]);
            }

            Console.WriteLine(dp[n - 1]);
        }
    }
}
0