結果

問題 No.2648 [Cherry 6th Tune D] 一次元の馬
ユーザー tobisatistobisatis
提出日時 2024-02-23 21:57:39
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 287 ms / 2,000 ms
コード長 2,455 bytes
コンパイル時間 9,694 ms
コンパイル使用メモリ 159,172 KB
実行使用メモリ 206,060 KB
最終ジャッジ日時 2024-02-23 21:57:57
合計ジャッジ時間 18,329 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
33,188 KB
testcase_01 AC 201 ms
57,124 KB
testcase_02 AC 175 ms
57,124 KB
testcase_03 AC 173 ms
57,124 KB
testcase_04 AC 168 ms
59,596 KB
testcase_05 AC 188 ms
71,472 KB
testcase_06 AC 175 ms
65,144 KB
testcase_07 AC 169 ms
70,384 KB
testcase_08 AC 171 ms
57,056 KB
testcase_09 AC 165 ms
69,952 KB
testcase_10 AC 163 ms
70,740 KB
testcase_11 AC 169 ms
57,976 KB
testcase_12 AC 172 ms
77,024 KB
testcase_13 AC 164 ms
69,320 KB
testcase_14 AC 161 ms
70,352 KB
testcase_15 AC 163 ms
70,460 KB
testcase_16 AC 164 ms
70,332 KB
testcase_17 AC 165 ms
70,328 KB
testcase_18 AC 189 ms
70,332 KB
testcase_19 AC 164 ms
70,328 KB
testcase_20 AC 165 ms
70,332 KB
testcase_21 AC 173 ms
70,320 KB
testcase_22 AC 163 ms
70,324 KB
testcase_23 AC 162 ms
70,320 KB
testcase_24 AC 166 ms
70,324 KB
testcase_25 AC 173 ms
55,856 KB
testcase_26 AC 165 ms
70,324 KB
testcase_27 AC 176 ms
75,156 KB
testcase_28 AC 165 ms
70,336 KB
testcase_29 AC 169 ms
68,944 KB
testcase_30 AC 162 ms
70,496 KB
testcase_31 AC 167 ms
70,336 KB
testcase_32 AC 168 ms
70,336 KB
testcase_33 AC 163 ms
71,624 KB
testcase_34 AC 163 ms
70,368 KB
testcase_35 AC 287 ms
206,060 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
/home/judge/data/code/Main.cs(36,40): warning CS8602: null 参照の可能性があるものの逆参照です。 [/home/judge/data/code/main.csproj]
  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 t = Int();
        var ans = new List<long>();
        for (var i = 0; i < t; i++)
        {
            ans.Add(Solve2());
        }
        Out(ans);
        return null;
    }

    long Solve2()
    {
        var n = Int();
        var az = n.Repeat(Int);
        bool F(int x)
        {
            var bz = new long[n];
            long lx = x;
            for (var i = 0; i < n; i++)
            {
                bz[i] = lx * (i + 1) + az[i];
            }
            for (var i = 1; i < n; i++)
            {
                if (bz[i] <= bz[i - 1]) return false;
            }
            return true;
        }
        int BinarySearch(int pass, int fail)
        {
            while (Math.Abs(pass - fail) > 1)
            {
                var middle = (pass + fail) >> 1;
                if (F(middle)) pass = middle; else fail = middle;
            }
            return pass;
        }
        var res = BinarySearch(int.MaxValue / 2 - 2, -1);
        return res;
    }

    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