結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2016-04-13 12:46:10 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 35 ms / 5,000 ms |
コード長 | 646 bytes |
コンパイル時間 | 3,657 ms |
コンパイル使用メモリ | 110,852 KB |
実行使用メモリ | 19,456 KB |
最終ジャッジ日時 | 2024-12-27 13:08:29 |
合計ジャッジ時間 | 4,229 ms |
ジャッジサーバーID (参考情報) |
judge1 / 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 No45_2 { public class Program { public static void Main(string[] args){ var n = int.Parse(Console.ReadLine()); var sushiList = new List<int>{0}; sushiList.AddRange(Console.ReadLine().Split().ToList().ConvertAll(int.Parse)); var dp = new List<int> {sushiList[0], sushiList[1], sushiList[n == 1 ? 1 : 2]}; for(var i = 3; i <= n; i++){ dp.Add(Math.Max(dp[i - 3], dp[i - 2]) + sushiList[i]); } Console.WriteLine(Math.Max(dp[n], dp[n - 1])); } } }