結果

問題 No.45 回転寿司
ユーザー ooh_20ooh_20
提出日時 2018-01-29 14:34:20
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 66 ms / 5,000 ms
コード長 1,563 bytes
コンパイル時間 2,818 ms
コンパイル使用メモリ 102,416 KB
実行使用メモリ 22,908 KB
最終ジャッジ日時 2023-08-27 16:00:03
合計ジャッジ時間 6,550 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 65 ms
22,856 KB
testcase_01 AC 65 ms
20,816 KB
testcase_02 AC 65 ms
20,776 KB
testcase_03 AC 65 ms
20,856 KB
testcase_04 AC 65 ms
22,744 KB
testcase_05 AC 56 ms
20,724 KB
testcase_06 AC 64 ms
22,856 KB
testcase_07 AC 65 ms
20,832 KB
testcase_08 AC 63 ms
20,704 KB
testcase_09 AC 65 ms
22,856 KB
testcase_10 AC 64 ms
20,680 KB
testcase_11 AC 64 ms
22,752 KB
testcase_12 AC 65 ms
22,864 KB
testcase_13 AC 57 ms
20,568 KB
testcase_14 AC 57 ms
20,744 KB
testcase_15 AC 66 ms
20,852 KB
testcase_16 AC 64 ms
20,836 KB
testcase_17 AC 65 ms
22,852 KB
testcase_18 AC 64 ms
20,840 KB
testcase_19 AC 65 ms
20,784 KB
testcase_20 AC 57 ms
20,644 KB
testcase_21 AC 57 ms
20,720 KB
testcase_22 AC 55 ms
20,608 KB
testcase_23 AC 56 ms
22,724 KB
testcase_24 AC 58 ms
22,700 KB
testcase_25 AC 57 ms
22,740 KB
testcase_26 AC 65 ms
22,828 KB
testcase_27 AC 64 ms
22,864 KB
testcase_28 AC 65 ms
22,908 KB
testcase_29 AC 64 ms
20,692 KB
testcase_30 AC 64 ms
20,768 KB
testcase_31 AC 56 ms
20,672 KB
testcase_32 AC 56 ms
20,600 KB
testcase_33 AC 65 ms
22,792 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)
            {
                if (V[0] > V[1])
                {
                    Console.WriteLine(V[0]);
                }
                else
                {
                    Console.WriteLine(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++)
                {
                    if (taste[i - 3] + V[i] > taste[i - 2] + V[i])
                    {
                        taste[i] = taste[i - 3] + V[i];
                    }
                    else
                    {
                        taste[i] = taste[i - 2] + V[i];
                    }
                }

                if (taste[N - 2] > taste[N - 1])
                {
                    Console.WriteLine(taste[N - 2]);
                }
                else
                {
                    Console.WriteLine(taste[N - 1]);
                }
            }
        }
    }
}
0