結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2017-08-25 14:06:41 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 35 ms / 5,000 ms |
コード長 | 717 bytes |
コンパイル時間 | 2,074 ms |
コンパイル使用メモリ | 106,368 KB |
実行使用メモリ | 19,712 KB |
最終ジャッジ日時 | 2024-12-27 16:55:28 |
合計ジャッジ時間 | 4,078 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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.
ソースコード
using System; using System.Collections.Generic; 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]; } } }