結果

問題 No.1651 Removing Cards
ユーザー 👑 kakel-sankakel-san
提出日時 2024-01-15 22:51:18
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 297 ms / 2,000 ms
コード長 1,395 bytes
コンパイル時間 6,862 ms
コンパイル使用メモリ 158,384 KB
実行使用メモリ 199,872 KB
最終ジャッジ日時 2024-01-15 22:51:37
合計ジャッジ時間 16,349 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 78 ms
32,932 KB
testcase_01 AC 76 ms
33,060 KB
testcase_02 AC 100 ms
37,284 KB
testcase_03 AC 78 ms
33,060 KB
testcase_04 AC 77 ms
33,188 KB
testcase_05 AC 77 ms
33,060 KB
testcase_06 AC 80 ms
33,188 KB
testcase_07 AC 76 ms
33,060 KB
testcase_08 AC 78 ms
33,188 KB
testcase_09 AC 164 ms
52,760 KB
testcase_10 AC 158 ms
52,772 KB
testcase_11 AC 159 ms
52,780 KB
testcase_12 AC 164 ms
52,784 KB
testcase_13 AC 166 ms
52,788 KB
testcase_14 AC 166 ms
52,796 KB
testcase_15 AC 297 ms
66,984 KB
testcase_16 AC 266 ms
66,984 KB
testcase_17 AC 270 ms
66,776 KB
testcase_18 AC 266 ms
66,984 KB
testcase_19 AC 267 ms
66,984 KB
testcase_20 AC 269 ms
66,996 KB
testcase_21 AC 268 ms
66,984 KB
testcase_22 AC 258 ms
70,656 KB
testcase_23 AC 172 ms
55,640 KB
testcase_24 AC 136 ms
45,988 KB
testcase_25 AC 230 ms
54,936 KB
testcase_26 AC 231 ms
54,936 KB
testcase_27 AC 273 ms
68,720 KB
testcase_28 AC 266 ms
68,724 KB
testcase_29 AC 268 ms
62,356 KB
testcase_30 AC 266 ms
62,356 KB
testcase_31 AC 277 ms
62,180 KB
testcase_32 AC 151 ms
48,292 KB
testcase_33 AC 155 ms
52,472 KB
testcase_34 AC 156 ms
199,872 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (91 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 string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (k, q) = (c[0], c[1]);
        var list = new List<decimal>{ 1 };
        while (list[^1] <= 1_000_000_000_000_000_000)
        {
            list.Add(decimal.Round(list[^1] * k / (k - 1), MidpointRounding.ToPositiveInfinity));
        }
        var ans = new decimal[q];
        for (var i = 0; i < q; ++i)
        {
            var n = long.Parse(ReadLine());
            var pos = LowerBound(0, n, list);
            ans[i] = n < list[pos] ? list[pos - 1] : list[pos];
        }
        WriteLine(string.Join("\n", ans));
    }
    static int LowerBound(int left, long min, List<decimal> list)
    {
        if (list[left] >= min) return left;
        var ng = left;
        var ok = list.Count;
        while (ok - ng > 1)
        {
            var center = (ng + ok) / 2;
            if (list[center] < min) ng = center;
            else ok = center;
        }
        return ok;
    }
}
0