結果

問題 No.2889 Rusk
ユーザー 👑 kakel-sankakel-san
提出日時 2024-09-13 22:38:41
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 217 ms / 2,000 ms
コード長 1,765 bytes
コンパイル時間 8,432 ms
コンパイル使用メモリ 164,684 KB
実行使用メモリ 266,344 KB
最終ジャッジ日時 2024-09-13 22:39:07
合計ジャッジ時間 17,073 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
30,080 KB
testcase_01 AC 58 ms
30,324 KB
testcase_02 AC 58 ms
30,464 KB
testcase_03 AC 57 ms
30,464 KB
testcase_04 AC 59 ms
30,328 KB
testcase_05 AC 58 ms
30,464 KB
testcase_06 AC 57 ms
30,464 KB
testcase_07 AC 58 ms
30,080 KB
testcase_08 AC 59 ms
30,080 KB
testcase_09 AC 59 ms
30,592 KB
testcase_10 AC 58 ms
30,080 KB
testcase_11 AC 58 ms
30,192 KB
testcase_12 AC 58 ms
30,592 KB
testcase_13 AC 58 ms
30,592 KB
testcase_14 AC 64 ms
33,152 KB
testcase_15 AC 91 ms
41,472 KB
testcase_16 AC 124 ms
60,528 KB
testcase_17 AC 88 ms
38,656 KB
testcase_18 AC 112 ms
56,704 KB
testcase_19 AC 146 ms
68,588 KB
testcase_20 AC 160 ms
79,600 KB
testcase_21 AC 153 ms
75,960 KB
testcase_22 AC 134 ms
64,060 KB
testcase_23 AC 127 ms
61,440 KB
testcase_24 AC 160 ms
78,520 KB
testcase_25 AC 128 ms
61,056 KB
testcase_26 AC 145 ms
68,008 KB
testcase_27 AC 164 ms
80,200 KB
testcase_28 AC 134 ms
62,204 KB
testcase_29 AC 134 ms
62,708 KB
testcase_30 AC 133 ms
62,960 KB
testcase_31 AC 160 ms
79,772 KB
testcase_32 AC 116 ms
57,600 KB
testcase_33 AC 86 ms
38,784 KB
testcase_34 AC 174 ms
87,444 KB
testcase_35 AC 178 ms
87,680 KB
testcase_36 AC 186 ms
87,552 KB
testcase_37 AC 185 ms
87,808 KB
testcase_38 AC 184 ms
87,552 KB
testcase_39 AC 145 ms
68,864 KB
testcase_40 AC 132 ms
57,456 KB
testcase_41 AC 147 ms
70,272 KB
testcase_42 AC 126 ms
57,088 KB
testcase_43 AC 103 ms
44,800 KB
testcase_44 AC 141 ms
66,432 KB
testcase_45 AC 126 ms
56,960 KB
testcase_46 AC 88 ms
39,664 KB
testcase_47 AC 103 ms
46,720 KB
testcase_48 AC 134 ms
63,104 KB
testcase_49 AC 58 ms
30,336 KB
testcase_50 AC 58 ms
30,324 KB
testcase_51 AC 58 ms
30,320 KB
testcase_52 AC 58 ms
30,080 KB
testcase_53 AC 59 ms
30,464 KB
testcase_54 AC 217 ms
266,344 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (93 ms)。
MSBuild のバージョン 17.9.6+a4ecab324 (.NET)
  main -> /home/judge/data/code/bin/Release/net8.0/main.dll
  main -> /home/judge/data/code/bin/Release/net8.0/publish/

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var a = NList;
        var b = NList;
        var c = NList;
        var dp = new long[5][];
        for (var i = 0; i < dp.Length; ++i) dp[i] = new long[n + 1];
        for (var i = 0; i < n; ++i)
        {
            var max = dp[0][i];
            dp[0][i + 1] = max + a[i];
            max = Math.Max(max, dp[1][i]);
            dp[1][i + 1] = max + b[i];
            max = Math.Max(max, dp[2][i]);
            dp[2][i + 1] = max + c[i];
            max = Math.Max(max, dp[3][i]);
            dp[3][i + 1] = max + b[i];
            max = Math.Max(max, dp[4][i]);
            dp[4][i + 1] = max + a[i];
        }
        var ans = dp.Max(di => di[n]);
        dp = new long[5][];
        for (var i = 0; i < dp.Length; ++i) dp[i] = new long[n + 1];
        for (var i = 0; i < n; ++i)
        {
            var max = dp[0][i];
            dp[0][i + 1] = max + a[i];
            max = Math.Max(max, dp[1][i]);
            dp[1][i + 1] = max + b[i];
            max = Math.Max(max, dp[2][i]);
            dp[2][i + 1] = max + a[i];
            max = Math.Max(max, dp[3][i]);
            dp[3][i + 1] = max + b[i];
            max = Math.Max(max, dp[4][i]);
            dp[4][i + 1] = max + a[i];
        }
        WriteLine(Math.Max(ans, dp.Max(di => di[n])));
    }
}
0