結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2018-02-19 22:57:25 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 794 bytes |
コンパイル時間 | 810 ms |
コンパイル使用メモリ | 107,824 KB |
実行使用メモリ | 28,004 KB |
最終ジャッジ日時 | 2024-07-16 03:51:52 |
合計ジャッジ時間 | 2,673 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 WA * 6 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.Linq; namespace _45 { class Program { static void Main(string[] args) { int n = int.Parse(Console.ReadLine()); int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray(); if (n == 0) Console.WriteLine(x[0]); else if (n == 1) Console.WriteLine(x.Max()); else if (n == 2) Console.WriteLine(Math.Max(x[0] + x[2],x[1])); else { int[] dp = new int[n]; dp[0] = x[0]; dp[1] = x[1]; dp[2] = dp[0] + x[2]; for (int i = 3; i < n; i++) { dp[i] = Math.Max(dp[i - 2],dp[i - 3]) + x[i]; } Console.WriteLine(dp[n - 1]); } } } }