結果
問題 |
No.45 回転寿司
|
ユーザー |
![]() |
提出日時 | 2018-01-29 14:58:26 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,118 bytes |
コンパイル時間 | 1,034 ms |
コンパイル使用メモリ | 110,280 KB |
実行使用メモリ | 24,212 KB |
最終ジャッジ日時 | 2024-12-29 18:06:12 |
合計ジャッジ時間 | 3,305 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 RE * 1 |
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.Collections.Generic; using System.IO; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ConsoleApplication6 { class Program { public static void Main(string[] args) { int N = int.Parse(Console.ReadLine()); int[] A = new int[N]; int[] B = new int[N]; string[] row = Console.ReadLine().Split(); for (int i = 0; i < N; i++) { A[i] = int.Parse(row[i]); } B[0] = A[0]; B[1] = A[1]; if(N == 1) { Console.WriteLine(A[0]); return; } for (int i = 0; i < N - 2; i++) { if (i + 2 < N && B[i+2] < B[i] + A[i+2]) { B[i + 2] = B[i] + A[i + 2]; } if (i + 3 < N && B[i] < B[i] + A[i + 3]) { B[i + 3] = B[i] + A[i + 3]; } } Console.WriteLine(B.Max()); } } }