結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
mencotton
|
| 提出日時 | 2017-12-29 21:44:37 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 840 bytes |
| コンパイル時間 | 911 ms |
| コンパイル使用メモリ | 111,400 KB |
| 実行使用メモリ | 27,928 KB |
| 最終ジャッジ日時 | 2024-12-21 10:37:28 |
| 合計ジャッジ時間 | 3,064 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 24 WA * 6 |
コンパイルメッセージ
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.Linq;
namespace Test
{
class Program
{
static void Main(string[] args)
{
int n = int.Parse(Console.ReadLine());
int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
if (n == 1) Console.WriteLine(x[0]);
else if (n == 2) Console.WriteLine(Math.Max(x[0],x[1]));
else if (n == 3) 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] = x[0] + x[2];
for (int i = 3; i < n; i++)
{
dp[i] = Math.Max(dp[i - 3],dp[i - 2]) + x[i];
}
Console.WriteLine(dp[n - 1]);
}
}
}
}
mencotton