結果

問題 No.45 回転寿司
ユーザー _matumo_
提出日時 2018-06-04 13:39:39
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 37 ms / 5,000 ms
コード長 896 bytes
コンパイル時間 3,994 ms
コンパイル使用メモリ 104,576 KB
実行使用メモリ 19,456 KB
最終ジャッジ日時 2024-12-27 18:57:15
合計ジャッジ時間 6,073 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.Collections.Generic;
using System.Linq;
using System.Text;

namespace YukiCoder
{
    class Program
    {
        static int nMax;
        static int[] pvi;
        static int[] pvo;

        static int zzz(int ni)
        {
            if (ni >= nMax) return 0;
            int nn = pvo[ni];
            if (nn > 0) return nn;

            int na = zzz(ni + 1);
            int nb = zzz(ni + 2) + pvi[ni];

            return pvo[ni] = na > nb ? na : nb;
        }
        //--------------------------------------------------------------//
        static void Main(string[] args)
        {
            nMax = int.Parse(Console.ReadLine());
            pvi = Console.ReadLine().Split().Select(int.Parse).ToArray();
            pvo = new Int32[nMax + 1];

            int n = zzz(0);

            Console.WriteLine(n);
            Console.ReadLine();
        }
    }
}

0