結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2015-12-29 15:59:29 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 675 bytes |
コンパイル時間 | 5,517 ms |
コンパイル使用メモリ | 104,192 KB |
実行使用メモリ | 18,688 KB |
最終ジャッジ日時 | 2024-12-27 12:39:19 |
合計ジャッジ時間 | 6,251 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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; namespace yukicoder { class _045 { static void Main() { int n = int.Parse(Console.ReadLine()); int[] vn = Array.ConvertAll(Console.ReadLine().Split(' ') , x => int.Parse(x)); int[] dp = new int[n]; dp[0] = vn[0]; if(n == 1) { Console.WriteLine(dp[n - 1]); return; } dp[1] = Math.Max(dp[0], vn[1]); for (int i = 2; i < n; i++) { dp[i] = Math.Max(dp[i - 1], dp[i - 2] + vn[i]); } Console.WriteLine(dp[n - 1]); } } }