結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー 👑 kakel-sankakel-san
提出日時 2024-03-22 21:59:50
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 168 ms / 2,000 ms
コード長 1,222 bytes
コンパイル時間 10,179 ms
コンパイル使用メモリ 158,844 KB
実行使用メモリ 205,456 KB
最終ジャッジ日時 2024-03-22 22:00:13
合計ジャッジ時間 19,717 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
32,548 KB
testcase_01 AC 77 ms
32,548 KB
testcase_02 AC 77 ms
32,548 KB
testcase_03 AC 77 ms
32,548 KB
testcase_04 AC 80 ms
32,804 KB
testcase_05 AC 77 ms
32,548 KB
testcase_06 AC 78 ms
33,060 KB
testcase_07 AC 77 ms
32,804 KB
testcase_08 AC 78 ms
32,932 KB
testcase_09 AC 80 ms
32,932 KB
testcase_10 AC 79 ms
32,932 KB
testcase_11 AC 77 ms
32,932 KB
testcase_12 AC 78 ms
32,804 KB
testcase_13 AC 77 ms
32,548 KB
testcase_14 AC 79 ms
32,932 KB
testcase_15 AC 79 ms
32,932 KB
testcase_16 AC 82 ms
32,932 KB
testcase_17 AC 79 ms
32,932 KB
testcase_18 AC 82 ms
32,932 KB
testcase_19 AC 79 ms
32,548 KB
testcase_20 AC 81 ms
32,932 KB
testcase_21 AC 79 ms
32,548 KB
testcase_22 AC 81 ms
32,932 KB
testcase_23 AC 81 ms
32,932 KB
testcase_24 AC 110 ms
45,644 KB
testcase_25 AC 107 ms
44,312 KB
testcase_26 AC 105 ms
42,148 KB
testcase_27 AC 119 ms
49,144 KB
testcase_28 AC 128 ms
51,720 KB
testcase_29 AC 95 ms
38,948 KB
testcase_30 AC 151 ms
60,036 KB
testcase_31 AC 124 ms
49,548 KB
testcase_32 AC 145 ms
61,348 KB
testcase_33 AC 147 ms
60,484 KB
testcase_34 AC 88 ms
34,468 KB
testcase_35 AC 118 ms
46,500 KB
testcase_36 AC 131 ms
53,204 KB
testcase_37 AC 154 ms
63,824 KB
testcase_38 AC 132 ms
53,284 KB
testcase_39 AC 94 ms
38,180 KB
testcase_40 AC 121 ms
49,536 KB
testcase_41 AC 97 ms
40,740 KB
testcase_42 AC 80 ms
33,444 KB
testcase_43 AC 84 ms
35,620 KB
testcase_44 AC 155 ms
64,108 KB
testcase_45 AC 150 ms
64,104 KB
testcase_46 AC 107 ms
45,408 KB
testcase_47 AC 104 ms
41,380 KB
testcase_48 AC 128 ms
51,728 KB
testcase_49 AC 141 ms
55,208 KB
testcase_50 AC 138 ms
55,208 KB
testcase_51 AC 138 ms
55,208 KB
testcase_52 AC 138 ms
55,204 KB
testcase_53 AC 141 ms
55,204 KB
testcase_54 AC 159 ms
67,496 KB
testcase_55 AC 164 ms
67,496 KB
testcase_56 AC 161 ms
67,484 KB
testcase_57 AC 160 ms
67,496 KB
testcase_58 AC 165 ms
67,496 KB
testcase_59 AC 162 ms
67,496 KB
testcase_60 AC 161 ms
67,496 KB
testcase_61 AC 161 ms
67,496 KB
testcase_62 AC 168 ms
67,496 KB
testcase_63 AC 163 ms
67,496 KB
testcase_64 AC 160 ms
67,496 KB
testcase_65 AC 161 ms
67,496 KB
testcase_66 AC 163 ms
67,496 KB
testcase_67 AC 158 ms
67,496 KB
testcase_68 AC 159 ms
67,496 KB
testcase_69 AC 145 ms
58,104 KB
testcase_70 AC 138 ms
58,104 KB
testcase_71 AC 137 ms
58,104 KB
testcase_72 AC 140 ms
58,104 KB
testcase_73 AC 138 ms
58,104 KB
testcase_74 AC 114 ms
49,192 KB
testcase_75 AC 139 ms
205,456 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (206 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.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 long[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, h) = (c[0], c[1]);
        var a = NList;
        var b = NList;
        var ans = 0L;
        var left = 0;
        var right = 0;
        var tire = 0L;
        var sat = 0L;
        var diffsum = 0L;
        while (true)
        {
            while (tire > h)
            {
                sat -= a[left];
                tire -= diffsum;
                diffsum -= b[left];
                ++left;
            }
            ans = Math.Max(ans, sat);
            if (right == n) break;
            sat += a[right];
            tire += (right - left + 1L) * b[right];
            diffsum += b[right];
            ++right;
            if (tire <= h) ans = Math.Max(ans, sat);
        }
        WriteLine(ans);
    }
}
0