結果
問題 |
No.45 回転寿司
|
ユーザー |
|
提出日時 | 2017-08-18 18:32:27 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 44 ms / 5,000 ms |
コード長 | 435 bytes |
コンパイル時間 | 2,664 ms |
コンパイル使用メモリ | 104,576 KB |
実行使用メモリ | 19,456 KB |
最終ジャッジ日時 | 2024-12-27 16:52:01 |
合計ジャッジ時間 | 5,278 ms |
ジャッジサーバーID (参考情報) |
judge2 / 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 { static void Main() { int n = int.Parse(Console.ReadLine()); int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray(); int[] sum = new int[n + 1]; sum[0] = 0; sum[1] = vs[0]; for (int i = 2; i <= n; i++) { sum[i] = Math.Max(sum[i - 2] + vs[i - 1], sum[i - 1]); } Console.WriteLine(sum[n]); } }