結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
ooh_20
|
| 提出日時 | 2018-01-29 14:40:13 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 31 ms / 5,000 ms |
| コード長 | 1,020 bytes |
| コンパイル時間 | 820 ms |
| コンパイル使用メモリ | 113,060 KB |
| 実行使用メモリ | 18,560 KB |
| 最終ジャッジ日時 | 2024-12-27 17:58:47 |
| 合計ジャッジ時間 | 2,795 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / 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)
{
Console.WriteLine(Math.Max(V[0], 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++)
{
taste[i] = Math.Max(taste[i - 3] + V[i], taste[i - 2] + V[i]);
}
Console.WriteLine(Math.Max(taste[N - 2], taste[N - 1]));
}
}
}
}
ooh_20