結果

問題 No.45 回転寿司
ユーザー masaktmasakt
提出日時 2017-04-03 02:25:00
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 61 ms / 5,000 ms
コード長 767 bytes
コンパイル時間 3,584 ms
コンパイル使用メモリ 102,836 KB
実行使用メモリ 22,896 KB
最終ジャッジ日時 2023-08-27 15:25:34
合計ジャッジ時間 5,017 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
20,744 KB
testcase_01 AC 61 ms
22,796 KB
testcase_02 AC 60 ms
22,896 KB
testcase_03 AC 61 ms
20,728 KB
testcase_04 AC 60 ms
20,820 KB
testcase_05 AC 51 ms
20,656 KB
testcase_06 AC 60 ms
18,724 KB
testcase_07 AC 59 ms
20,736 KB
testcase_08 AC 58 ms
20,892 KB
testcase_09 AC 60 ms
20,740 KB
testcase_10 AC 60 ms
22,800 KB
testcase_11 AC 59 ms
20,896 KB
testcase_12 AC 59 ms
20,816 KB
testcase_13 AC 51 ms
20,696 KB
testcase_14 AC 52 ms
18,616 KB
testcase_15 AC 57 ms
20,748 KB
testcase_16 AC 58 ms
20,832 KB
testcase_17 AC 57 ms
20,868 KB
testcase_18 AC 56 ms
20,788 KB
testcase_19 AC 59 ms
22,876 KB
testcase_20 AC 50 ms
22,636 KB
testcase_21 AC 51 ms
20,840 KB
testcase_22 AC 52 ms
20,744 KB
testcase_23 AC 53 ms
22,776 KB
testcase_24 AC 53 ms
18,544 KB
testcase_25 AC 52 ms
20,768 KB
testcase_26 AC 58 ms
18,808 KB
testcase_27 AC 59 ms
20,816 KB
testcase_28 AC 58 ms
20,848 KB
testcase_29 AC 59 ms
18,696 KB
testcase_30 AC 60 ms
22,792 KB
testcase_31 AC 52 ms
20,712 KB
testcase_32 AC 53 ms
20,740 KB
testcase_33 AC 60 ms
20,944 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;

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[1010];
    static int[] dp = new int[1010];

    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