結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
21,728 KB
testcase_01 AC 67 ms
21,808 KB
testcase_02 AC 69 ms
21,780 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 60 ms
21,684 KB
testcase_06 AC 68 ms
19,800 KB
testcase_07 WA -
testcase_08 AC 67 ms
21,736 KB
testcase_09 AC 68 ms
19,792 KB
testcase_10 AC 67 ms
21,720 KB
testcase_11 AC 67 ms
21,804 KB
testcase_12 WA -
testcase_13 AC 61 ms
21,656 KB
testcase_14 WA -
testcase_15 AC 68 ms
21,804 KB
testcase_16 AC 67 ms
21,912 KB
testcase_17 AC 68 ms
21,748 KB
testcase_18 AC 69 ms
23,704 KB
testcase_19 AC 69 ms
23,768 KB
testcase_20 AC 61 ms
21,824 KB
testcase_21 AC 61 ms
21,680 KB
testcase_22 AC 60 ms
19,584 KB
testcase_23 AC 61 ms
21,756 KB
testcase_24 AC 61 ms
21,596 KB
testcase_25 AC 60 ms
23,576 KB
testcase_26 AC 69 ms
23,812 KB
testcase_27 AC 69 ms
23,788 KB
testcase_28 AC 68 ms
21,776 KB
testcase_29 WA -
testcase_30 AC 68 ms
21,720 KB
testcase_31 AC 61 ms
19,624 KB
testcase_32 AC 62 ms
23,752 KB
testcase_33 AC 69 ms
21,664 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 (x.Length == 1) Console.WriteLine(x[0]);
            else if (x.Length == 2) Console.WriteLine(Math.Max(x[0],x[1]));
            else if (x.Length == 3) Console.WriteLine(Math.Max(x[0] + x[2],x[1]));
            else
            {
                int[] dp = new int[x.Length];
                dp[0] = x[0]; dp[1] = x[1]; dp[2] = x[0] + x[2];
                for (int i = 3; i < x.Length; i++)
                {
                    dp[i] = Math.Max(dp[i - 3],dp[i - 2]) + x[i];
                }
                Console.WriteLine(dp[x.Length - 1]);
            }
        }
    }
}
0