結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2017-04-03 02:22:59 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 767 bytes |
コンパイル時間 | 1,383 ms |
コンパイル使用メモリ | 104,448 KB |
実行使用メモリ | 18,944 KB |
最終ジャッジ日時 | 2024-07-08 00:26:05 |
合計ジャッジ時間 | 2,973 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 RE * 1 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; class P { static int Search(int i) { if (dp[i] > 0) { return dp[i]; } int res = 0; if(i >= n) { res = 0; } else { res = Math.Max(Search(i + 2), Search(i + 3)) + V[i]; } return dp[i] = res; } static int n; static int[] V = new int[1000]; static int[] dp = new int[1000]; static void Main(string[]_) { n = int.Parse(Console.ReadLine()); _=Console.ReadLine().Split(' '); for (int i = 0; i < n; i++) { V[i] = int.Parse(_[i]); } Console.WriteLine(Math.Max(Search(0),Search(1))); } }