結果

問題 No.45 回転寿司
ユーザー ooh_20ooh_20
提出日時 2018-01-29 14:40:13
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 59 ms / 5,000 ms
コード長 1,020 bytes
コンパイル時間 1,878 ms
コンパイル使用メモリ 104,060 KB
実行使用メモリ 22,900 KB
最終ジャッジ日時 2023-08-27 16:00:55
合計ジャッジ時間 4,993 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
20,920 KB
testcase_01 AC 56 ms
20,924 KB
testcase_02 AC 57 ms
22,812 KB
testcase_03 AC 56 ms
20,848 KB
testcase_04 AC 57 ms
22,884 KB
testcase_05 AC 49 ms
20,668 KB
testcase_06 AC 56 ms
18,820 KB
testcase_07 AC 58 ms
22,892 KB
testcase_08 AC 55 ms
20,852 KB
testcase_09 AC 58 ms
20,808 KB
testcase_10 AC 57 ms
20,828 KB
testcase_11 AC 56 ms
20,836 KB
testcase_12 AC 59 ms
20,884 KB
testcase_13 AC 50 ms
20,756 KB
testcase_14 AC 49 ms
20,684 KB
testcase_15 AC 57 ms
22,876 KB
testcase_16 AC 56 ms
18,812 KB
testcase_17 AC 57 ms
22,900 KB
testcase_18 AC 56 ms
22,868 KB
testcase_19 AC 57 ms
20,844 KB
testcase_20 AC 51 ms
20,780 KB
testcase_21 AC 49 ms
20,724 KB
testcase_22 AC 49 ms
20,760 KB
testcase_23 AC 50 ms
20,828 KB
testcase_24 AC 50 ms
20,672 KB
testcase_25 AC 51 ms
20,596 KB
testcase_26 AC 58 ms
18,796 KB
testcase_27 AC 57 ms
20,772 KB
testcase_28 AC 56 ms
20,784 KB
testcase_29 AC 57 ms
20,852 KB
testcase_30 AC 56 ms
20,868 KB
testcase_31 AC 51 ms
22,676 KB
testcase_32 AC 51 ms
22,728 KB
testcase_33 AC 58 ms
20,720 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;

namespace ConsoleApp32
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string[] row = Console.ReadLine().Split();
            int[] V = new int[N];
            for (int i = 0; i < N; i++)
            {
                V[i] = int.Parse(row[i]);
            }

            if (N == 1)
            {
                Console.WriteLine(V[0]);
            }
            else if (N == 2)
            {
                Console.WriteLine(Math.Max(V[0], V[1]));
            }
            else
            {
                int[] taste = new int[N];
                taste[0] = V[0];
                taste[1] = V[1];
                taste[2] = V[0] + V[2];

                for (int i = 3; i < N; i++)
                {
                    taste[i] = Math.Max(taste[i - 3] + V[i], taste[i - 2] + V[i]);
                }

                Console.WriteLine(Math.Max(taste[N - 2], taste[N - 1]));
            }
        }
    }
}
0