結果

問題 No.2694 The Early Bird Catches The Worm
ユーザー tobisatistobisatis
提出日時 2024-03-22 21:37:12
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 2,212 bytes
コンパイル時間 7,349 ms
コンパイル使用メモリ 157,636 KB
実行使用メモリ 205,424 KB
最終ジャッジ日時 2024-03-22 21:37:34
合計ジャッジ時間 19,592 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
32,676 KB
testcase_01 AC 77 ms
32,676 KB
testcase_02 AC 78 ms
32,676 KB
testcase_03 AC 78 ms
32,676 KB
testcase_04 AC 78 ms
32,932 KB
testcase_05 AC 76 ms
32,676 KB
testcase_06 AC 78 ms
33,060 KB
testcase_07 AC 77 ms
32,932 KB
testcase_08 AC 80 ms
32,932 KB
testcase_09 AC 77 ms
32,932 KB
testcase_10 AC 79 ms
32,932 KB
testcase_11 AC 80 ms
32,932 KB
testcase_12 AC 78 ms
32,932 KB
testcase_13 AC 78 ms
32,676 KB
testcase_14 AC 78 ms
32,932 KB
testcase_15 AC 77 ms
32,932 KB
testcase_16 AC 77 ms
32,932 KB
testcase_17 AC 78 ms
32,932 KB
testcase_18 AC 77 ms
32,932 KB
testcase_19 AC 77 ms
32,676 KB
testcase_20 AC 79 ms
32,932 KB
testcase_21 AC 77 ms
32,676 KB
testcase_22 AC 79 ms
32,932 KB
testcase_23 AC 79 ms
32,932 KB
testcase_24 AC 108 ms
43,440 KB
testcase_25 AC 103 ms
42,148 KB
testcase_26 AC 109 ms
44,772 KB
testcase_27 AC 117 ms
48,216 KB
testcase_28 AC 118 ms
50,024 KB
testcase_29 AC 91 ms
39,076 KB
testcase_30 AC 141 ms
60,164 KB
testcase_31 AC 118 ms
48,620 KB
testcase_32 AC 149 ms
61,452 KB
testcase_33 AC 142 ms
60,608 KB
testcase_34 AC 83 ms
34,596 KB
testcase_35 AC 113 ms
46,876 KB
testcase_36 AC 123 ms
51,108 KB
testcase_37 AC 154 ms
64,028 KB
testcase_38 AC 128 ms
53,412 KB
testcase_39 AC 91 ms
38,308 KB
testcase_40 AC 118 ms
48,476 KB
testcase_41 AC 98 ms
40,740 KB
testcase_42 AC 83 ms
33,444 KB
testcase_43 AC 87 ms
35,748 KB
testcase_44 AC 153 ms
64,180 KB
testcase_45 AC 149 ms
64,184 KB
testcase_46 AC 105 ms
43,128 KB
testcase_47 AC 105 ms
43,788 KB
testcase_48 AC 118 ms
50,028 KB
testcase_49 AC 139 ms
54,180 KB
testcase_50 AC 148 ms
54,180 KB
testcase_51 AC 139 ms
54,180 KB
testcase_52 AC 140 ms
54,180 KB
testcase_53 AC 139 ms
54,180 KB
testcase_54 AC 157 ms
67,660 KB
testcase_55 AC 159 ms
67,660 KB
testcase_56 AC 158 ms
67,648 KB
testcase_57 AC 158 ms
67,660 KB
testcase_58 AC 161 ms
67,660 KB
testcase_59 AC 160 ms
67,660 KB
testcase_60 AC 158 ms
67,660 KB
testcase_61 AC 157 ms
67,656 KB
testcase_62 AC 158 ms
67,664 KB
testcase_63 AC 159 ms
67,664 KB
testcase_64 AC 158 ms
67,664 KB
testcase_65 AC 160 ms
67,664 KB
testcase_66 AC 159 ms
67,664 KB
testcase_67 AC 156 ms
67,664 KB
testcase_68 AC 158 ms
67,664 KB
testcase_69 AC 143 ms
58,276 KB
testcase_70 AC 144 ms
58,276 KB
testcase_71 AC 143 ms
58,276 KB
testcase_72 AC 150 ms
58,272 KB
testcase_73 AC 144 ms
58,276 KB
testcase_74 AC 112 ms
45,860 KB
testcase_75 AC 144 ms
205,424 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (108 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 #

namespace AtCoder;

#nullable enable

using System.Numerics;

static class Extensions
{
    public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray();
}

class AtCoder
{
    object? Solve()
    {
        var n = Int();
        var h = Int();
        var az = n.Repeat(Int);
        var bz = n.Repeat(Int);
        var ans = 0L;
        var av = 0L;
        var ah = 0L;
        var sh = 0L;
        var r = 0;
        for (var l = 0; l < n; l++)
        {
            while (r < n)
            {
                long w = r - l + 1;
                if (w * bz[r] + ah <= h)
                {
                    ah += w * bz[r];
                    sh += bz[r];
                    av += az[r];
                    r++;
                    continue;
                }
                break;
            }
            ans = Math.Max(ans, av);
            av -= az[l];
            ah -= sh;
            sh -= bz[l];
        }
        return ans;
    }

    public static void Main() => new AtCoder().Run();
    public void Run()
    {
        var res = Solve();
        if (res != null)
        {
            if (res is bool yes) res = yes ? "Yes" : "No";
            sw.WriteLine(res);
        }
        sw.Flush();
    }

    string[] input = Array.Empty<string>();
    int iter = 0;
    readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false };

    #pragma warning disable IDE0051
    string String()
    {
        while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Split(' '), 0);
        return input[iter++];
    }
    T Input<T>() where T : IParsable<T> => T.Parse(String(), null);
    int Int() => Input<int>();
    void Out(object? x, string? separator = null)
    {
        separator ??= Environment.NewLine;
        if (x is System.Collections.IEnumerable obj and not string)
        {
            var firstLine = true;
            foreach (var item in obj)
            {
                if (!firstLine) sw.Write(separator);
                firstLine = false;
                sw.Write(item);
            }
        }
        else sw.Write(x);
        sw.WriteLine();
    }
    #pragma warning restore IDE0051
}
0