結果

問題 No.45 回転寿司
ユーザー mencottonmencotton
提出日時 2018-02-19 22:57:25
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 794 bytes
コンパイル時間 2,155 ms
コンパイル使用メモリ 102,916 KB
実行使用メモリ 25,740 KB
最終ジャッジ日時 2023-09-23 03:38:36
合計ジャッジ時間 6,035 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
21,672 KB
testcase_01 AC 69 ms
21,860 KB
testcase_02 AC 68 ms
21,780 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 61 ms
21,576 KB
testcase_06 AC 69 ms
21,620 KB
testcase_07 WA -
testcase_08 AC 67 ms
21,764 KB
testcase_09 AC 67 ms
21,720 KB
testcase_10 AC 68 ms
21,608 KB
testcase_11 AC 68 ms
23,808 KB
testcase_12 WA -
testcase_13 AC 59 ms
21,552 KB
testcase_14 WA -
testcase_15 AC 68 ms
21,844 KB
testcase_16 AC 67 ms
21,672 KB
testcase_17 AC 68 ms
19,732 KB
testcase_18 AC 67 ms
23,728 KB
testcase_19 AC 68 ms
23,688 KB
testcase_20 AC 61 ms
21,684 KB
testcase_21 AC 61 ms
21,652 KB
testcase_22 AC 61 ms
23,704 KB
testcase_23 AC 61 ms
21,672 KB
testcase_24 AC 62 ms
25,668 KB
testcase_25 AC 61 ms
21,484 KB
testcase_26 AC 68 ms
21,668 KB
testcase_27 AC 69 ms
21,784 KB
testcase_28 AC 69 ms
23,768 KB
testcase_29 WA -
testcase_30 AC 69 ms
21,688 KB
testcase_31 AC 60 ms
21,708 KB
testcase_32 RE -
testcase_33 AC 68 ms
25,724 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.Linq;

namespace _45
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
            if (n == 0) Console.WriteLine(x[0]);
            else if (n == 1) Console.WriteLine(x.Max());
            else if (n == 2) Console.WriteLine(Math.Max(x[0] + x[2],x[1]));
            else
            {
                int[] dp = new int[n];
                dp[0] = x[0]; dp[1] = x[1]; dp[2] = dp[0] + x[2];
                for (int i = 3; i < n; i++)
                {
                    dp[i] = Math.Max(dp[i - 2],dp[i - 3]) + x[i];
                }
                Console.WriteLine(dp[n - 1]);
            }
        }
    }
}
0