結果
| 問題 |
No.45 回転寿司
|
| ユーザー |
ooh_23
|
| 提出日時 | 2018-01-29 15:00:42 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 38 ms / 5,000 ms |
| コード長 | 1,119 bytes |
| コンパイル時間 | 1,121 ms |
| コンパイル使用メモリ | 105,472 KB |
| 実行使用メモリ | 19,328 KB |
| 最終ジャッジ日時 | 2024-12-27 17:57:45 |
| 合計ジャッジ時間 | 3,482 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
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]);
}
if (N == 1)
{
Console.WriteLine(A[0]);
return;
}
B[0] = A[0];
B[1] = A[1];
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());
}
}
}
ooh_23