結果

問題 No.45 回転寿司
ユーザー mencottonmencotton
提出日時 2017-12-29 21:44:37
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 840 bytes
コンパイル時間 2,113 ms
コンパイル使用メモリ 104,292 KB
実行使用メモリ 23,980 KB
最終ジャッジ日時 2023-08-23 09:04:51
合計ジャッジ時間 5,897 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
21,804 KB
testcase_01 AC 67 ms
23,808 KB
testcase_02 AC 68 ms
21,784 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 59 ms
23,812 KB
testcase_06 AC 66 ms
21,792 KB
testcase_07 WA -
testcase_08 AC 66 ms
21,848 KB
testcase_09 AC 66 ms
19,808 KB
testcase_10 AC 67 ms
21,752 KB
testcase_11 AC 67 ms
21,748 KB
testcase_12 WA -
testcase_13 AC 59 ms
21,664 KB
testcase_14 WA -
testcase_15 AC 67 ms
21,732 KB
testcase_16 AC 66 ms
23,768 KB
testcase_17 AC 68 ms
23,824 KB
testcase_18 AC 66 ms
21,784 KB
testcase_19 AC 66 ms
21,756 KB
testcase_20 AC 59 ms
21,592 KB
testcase_21 AC 61 ms
23,828 KB
testcase_22 AC 60 ms
21,716 KB
testcase_23 AC 60 ms
21,584 KB
testcase_24 AC 59 ms
23,676 KB
testcase_25 AC 58 ms
21,836 KB
testcase_26 AC 67 ms
19,696 KB
testcase_27 AC 68 ms
21,760 KB
testcase_28 AC 67 ms
21,772 KB
testcase_29 WA -
testcase_30 AC 66 ms
23,752 KB
testcase_31 AC 59 ms
21,728 KB
testcase_32 AC 59 ms
21,744 KB
testcase_33 AC 67 ms
21,808 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;

namespace Test
{
    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(Math.Max(x[0],x[1]));
            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] = x[0] + x[2];
                for (int i = 3; i < n; i++)
                {
                    dp[i] = Math.Max(dp[i - 3],dp[i - 2]) + x[i];
                }
                Console.WriteLine(dp[n - 1]);
            }
        }
    }
}
0