結果

問題 No.45 回転寿司
ユーザー ooh_23ooh_23
提出日時 2018-01-29 15:00:42
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 70 ms / 5,000 ms
コード長 1,119 bytes
コンパイル時間 2,155 ms
コンパイル使用メモリ 104,396 KB
実行使用メモリ 23,712 KB
最終ジャッジ日時 2023-08-27 16:00:11
合計ジャッジ時間 5,952 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
23,700 KB
testcase_01 AC 70 ms
21,668 KB
testcase_02 AC 70 ms
23,596 KB
testcase_03 AC 68 ms
19,608 KB
testcase_04 AC 69 ms
21,520 KB
testcase_05 AC 62 ms
23,508 KB
testcase_06 AC 69 ms
21,636 KB
testcase_07 AC 69 ms
21,520 KB
testcase_08 AC 68 ms
21,708 KB
testcase_09 AC 67 ms
19,468 KB
testcase_10 AC 69 ms
21,568 KB
testcase_11 AC 67 ms
21,552 KB
testcase_12 AC 68 ms
21,728 KB
testcase_13 AC 60 ms
21,472 KB
testcase_14 AC 60 ms
21,404 KB
testcase_15 AC 69 ms
21,508 KB
testcase_16 AC 69 ms
23,652 KB
testcase_17 AC 69 ms
19,572 KB
testcase_18 AC 68 ms
21,648 KB
testcase_19 AC 70 ms
21,556 KB
testcase_20 AC 61 ms
21,428 KB
testcase_21 AC 61 ms
21,472 KB
testcase_22 AC 62 ms
23,564 KB
testcase_23 AC 61 ms
21,412 KB
testcase_24 AC 63 ms
21,416 KB
testcase_25 AC 59 ms
21,440 KB
testcase_26 AC 69 ms
19,568 KB
testcase_27 AC 69 ms
21,572 KB
testcase_28 AC 70 ms
21,668 KB
testcase_29 AC 70 ms
23,712 KB
testcase_30 AC 70 ms
21,584 KB
testcase_31 AC 62 ms
21,432 KB
testcase_32 AC 61 ms
21,468 KB
testcase_33 AC 70 ms
21,512 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

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());
        }
    }
}
0