結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2014-10-27 01:19:29 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 37 ms / 5,000 ms |
コード長 | 499 bytes |
コンパイル時間 | 836 ms |
コンパイル使用メモリ | 113,980 KB |
実行使用メモリ | 19,712 KB |
最終ジャッジ日時 | 2024-12-27 10:45:51 |
合計ジャッジ時間 | 2,920 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.Linq; class Program { public static void Main(string[] args) { var n = int.Parse(Console.ReadLine()); var vs = Console.ReadLine().Split(' ').Select(element => int.Parse(element)).ToArray(); var dp = new int[n+1]; dp[0] = 0; dp[1] = vs[0]; for (int i = 2; i <= n; i++) { dp[i] = Math.Max(dp[i - 2] + vs[i - 1], dp[i - 1]); } Console.WriteLine(dp[n]); } }