結果

問題 No.45 回転寿司
ユーザー masaktmasakt
提出日時 2017-04-03 02:23:59
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 767 bytes
コンパイル時間 2,054 ms
コンパイル使用メモリ 103,300 KB
実行使用メモリ 22,928 KB
最終ジャッジ日時 2023-09-22 08:01:30
合計ジャッジ時間 5,779 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 63 ms
20,920 KB
testcase_01 AC 66 ms
22,876 KB
testcase_02 AC 66 ms
20,744 KB
testcase_03 AC 65 ms
18,740 KB
testcase_04 AC 63 ms
22,780 KB
testcase_05 AC 56 ms
18,628 KB
testcase_06 AC 65 ms
22,928 KB
testcase_07 AC 63 ms
18,744 KB
testcase_08 AC 63 ms
22,824 KB
testcase_09 AC 64 ms
20,796 KB
testcase_10 AC 64 ms
20,672 KB
testcase_11 AC 63 ms
22,868 KB
testcase_12 AC 65 ms
22,924 KB
testcase_13 AC 56 ms
22,740 KB
testcase_14 AC 57 ms
22,796 KB
testcase_15 AC 64 ms
20,864 KB
testcase_16 AC 63 ms
22,880 KB
testcase_17 AC 64 ms
20,992 KB
testcase_18 AC 63 ms
18,808 KB
testcase_19 AC 64 ms
18,860 KB
testcase_20 AC 57 ms
22,728 KB
testcase_21 AC 59 ms
22,716 KB
testcase_22 AC 57 ms
20,672 KB
testcase_23 AC 56 ms
20,796 KB
testcase_24 AC 57 ms
20,684 KB
testcase_25 AC 56 ms
20,888 KB
testcase_26 AC 65 ms
20,668 KB
testcase_27 AC 65 ms
20,792 KB
testcase_28 AC 64 ms
20,684 KB
testcase_29 AC 64 ms
20,788 KB
testcase_30 AC 63 ms
20,896 KB
testcase_31 AC 56 ms
22,688 KB
testcase_32 AC 57 ms
20,800 KB
testcase_33 RE -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;

class P
{
    static int Search(int i)
    {
        if (dp[i] > 0)
        {
            return dp[i];
        }
        int res = 0;
        if(i >= n)
        {
            res = 0;
        }
        else
        {
            res = Math.Max(Search(i + 2), Search(i + 3)) + V[i];
        }
        return dp[i] = res;
    }
    static int n;
    static int[] V = new int[1001];
    static int[] dp = new int[1001];

    static void Main(string[]_)
    {
        n = int.Parse(Console.ReadLine());
        _=Console.ReadLine().Split(' ');
        for (int i = 0; i < n; i++)
        {
            V[i] = int.Parse(_[i]);
        }
        Console.WriteLine(Math.Max(Search(0),Search(1)));
    }
}
0