結果
| 問題 | No.45 回転寿司 |
| ユーザー |
mencotton
|
| 提出日時 | 2017-12-29 21:55:45 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 882 bytes |
| 記録 | |
| コンパイル時間 | 947 ms |
| コンパイル使用メモリ | 111,792 KB |
| 実行使用メモリ | 27,760 KB |
| 最終ジャッジ日時 | 2024-12-21 10:37:36 |
| 合計ジャッジ時間 | 2,822 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 (x.Length == 1) Console.WriteLine(x[0]);
else if (x.Length == 2) Console.WriteLine(Math.Max(x[0],x[1]));
else if (x.Length == 3) Console.WriteLine(Math.Max(x[0] + x[2],x[1]));
else
{
int[] dp = new int[x.Length];
dp[0] = x[0]; dp[1] = x[1]; dp[2] = x[0] + x[2];
for (int i = 3; i < x.Length; i++)
{
dp[i] = Math.Max(dp[i - 3],dp[i - 2]) + x[i];
}
Console.WriteLine(dp[x.Length - 1]);
}
}
}
}
mencotton