結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
23,744 KB
testcase_01 AC 68 ms
21,632 KB
testcase_02 AC 69 ms
21,700 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 62 ms
25,672 KB
testcase_06 AC 69 ms
19,624 KB
testcase_07 WA -
testcase_08 AC 67 ms
21,672 KB
testcase_09 AC 68 ms
21,892 KB
testcase_10 AC 69 ms
21,640 KB
testcase_11 AC 67 ms
23,668 KB
testcase_12 WA -
testcase_13 AC 61 ms
23,660 KB
testcase_14 WA -
testcase_15 AC 68 ms
21,708 KB
testcase_16 AC 68 ms
21,760 KB
testcase_17 AC 68 ms
23,720 KB
testcase_18 AC 67 ms
21,620 KB
testcase_19 AC 69 ms
23,760 KB
testcase_20 AC 60 ms
21,672 KB
testcase_21 AC 61 ms
23,612 KB
testcase_22 AC 60 ms
21,624 KB
testcase_23 AC 61 ms
21,544 KB
testcase_24 AC 60 ms
23,668 KB
testcase_25 AC 60 ms
23,596 KB
testcase_26 AC 68 ms
21,704 KB
testcase_27 AC 68 ms
21,684 KB
testcase_28 AC 68 ms
21,704 KB
testcase_29 WA -
testcase_30 AC 69 ms
21,596 KB
testcase_31 AC 60 ms
21,564 KB
testcase_32 AC 61 ms
19,628 KB
testcase_33 AC 69 ms
21,684 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 == 1) Console.WriteLine(x[0]);
            else if (n == 2) Console.WriteLine(x.Max());
            else if (n == 3) 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