結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2016-11-28 01:41:09 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 929 bytes |
コンパイル時間 | 4,073 ms |
コンパイル使用メモリ | 106,624 KB |
実行使用メモリ | 42,880 KB |
最終ジャッジ日時 | 2024-11-27 12:29:33 |
合計ジャッジ時間 | 178,182 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 2 TLE * 28 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Linq; namespace No45 { class Program { private static int N; private static int[] Vs; static void Main(string[] args) { N = int.Parse(Console.ReadLine()); Vs = Console.ReadLine().Split(' ').Select(v => int.Parse(v)).ToArray(); var result = Rec(); Console.Write(result); } static int Rec() { return Enumerable.Range(0, N) .Select(i => Rec(i)) .Max(); } static int Rec(int index) { if (index == N - 2) return Vs[index]; if (index == N - 1) return Vs[index]; var max = Enumerable.Range(index + 2, N - index - 2) .Select(i => Rec(i) + Vs[index]) .DefaultIfEmpty() .Max(); return Math.Max(max, Vs[index]); } } }