結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2018-01-29 14:34:20 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 1,563 bytes |
コンパイル時間 | 2,618 ms |
コンパイル使用メモリ | 103,680 KB |
実行使用メモリ | 18,432 KB |
最終ジャッジ日時 | 2024-12-27 17:57:29 |
合計ジャッジ時間 | 4,707 ms |
ジャッジサーバーID (参考情報) |
judge3 / 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; namespace ConsoleApp32 { class Program { static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); string[] row = Console.ReadLine().Split(); int[] V = new int[N]; for (int i = 0; i < N; i++) { V[i] = int.Parse(row[i]); } if (N == 1) { Console.WriteLine(V[0]); } else if (N == 2) { if (V[0] > V[1]) { Console.WriteLine(V[0]); } else { Console.WriteLine(V[1]); } } else { int[] taste = new int[N]; taste[0] = V[0]; taste[1] = V[1]; taste[2] = V[0] + V[2]; for (int i = 3; i < N; i++) { if (taste[i - 3] + V[i] > taste[i - 2] + V[i]) { taste[i] = taste[i - 3] + V[i]; } else { taste[i] = taste[i - 2] + V[i]; } } if (taste[N - 2] > taste[N - 1]) { Console.WriteLine(taste[N - 2]); } else { Console.WriteLine(taste[N - 1]); } } } } }