結果

問題 No.45 回転寿司
ユーザー mori_chibi
提出日時 2017-08-25 14:07:49
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 47 ms / 5,000 ms
コード長 683 bytes
コンパイル時間 2,304 ms
コンパイル使用メモリ 106,496 KB
実行使用メモリ 19,584 KB
最終ジャッジ日時 2024-12-27 17:02:09
合計ジャッジ時間 4,605 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 30
権限があれば一括ダウンロードができます
コンパイルメッセージ
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.Linq;

namespace KaitenSushi
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] P = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
            int R = MainProcess(N,P);
            Console.WriteLine(R);

        }

        private static int MainProcess(int N,int[] P)
        {
            int[] M = new int[N + 1];
            M[0] = 0;
            M[1] = P[0];
            for(int i = 2; i < N + 1; i++)
            {
                M[i] = Math.Max(M[i - 1], M[i - 2] + P[i - 1]);
            }
            return M[N];
        }
    }
}
0