結果

問題 No.2227 King Kraken's Attack
ユーザー 👑 kakel-sankakel-san
提出日時 2023-02-24 22:13:03
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,947 bytes
コンパイル時間 832 ms
コンパイル使用メモリ 111,356 KB
実行使用メモリ 29,332 KB
最終ジャッジ日時 2024-04-10 09:24:05
合計ジャッジ時間 11,332 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
24,960 KB
testcase_01 AC 27 ms
24,964 KB
testcase_02 AC 27 ms
22,840 KB
testcase_03 AC 30 ms
26,880 KB
testcase_04 AC 28 ms
27,028 KB
testcase_05 AC 27 ms
25,216 KB
testcase_06 AC 27 ms
25,228 KB
testcase_07 AC 26 ms
24,880 KB
testcase_08 AC 27 ms
22,832 KB
testcase_09 AC 27 ms
24,752 KB
testcase_10 AC 26 ms
25,360 KB
testcase_11 AC 26 ms
22,964 KB
testcase_12 AC 26 ms
24,960 KB
testcase_13 AC 26 ms
24,964 KB
testcase_14 AC 27 ms
27,140 KB
testcase_15 AC 27 ms
22,836 KB
testcase_16 AC 27 ms
25,092 KB
testcase_17 AC 1,440 ms
25,008 KB
testcase_18 WA -
testcase_19 AC 27 ms
25,212 KB
testcase_20 AC 44 ms
25,088 KB
testcase_21 AC 268 ms
27,012 KB
testcase_22 AC 213 ms
22,832 KB
testcase_23 AC 37 ms
25,116 KB
testcase_24 AC 338 ms
24,988 KB
testcase_25 AC 1,381 ms
27,128 KB
testcase_26 AC 1,612 ms
22,964 KB
testcase_27 WA -
testcase_28 AC 77 ms
25,244 KB
testcase_29 AC 50 ms
23,220 KB
testcase_30 AC 426 ms
27,388 KB
testcase_31 AC 86 ms
27,136 KB
testcase_32 AC 40 ms
25,348 KB
testcase_33 AC 40 ms
27,136 KB
testcase_34 AC 33 ms
25,112 KB
testcase_35 AC 49 ms
24,824 KB
testcase_36 AC 39 ms
25,112 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 28 ms
25,132 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static long[] NList => ReadLine().Split().Select(long.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (h, w, la, lb, ka, kb) = (c[0], c[1], c[2], c[3], c[4], c[5]);
        WriteLine(Attack(h, w, la, lb, ka, kb));
    }
    static long Attack(long h, long w, long la, long lb, long ka, long kb)
    {
        var horimax = (h + la - 1) / la;
        var vertmax = (w + lb - 1) / lb;
        var kmax = Math.Max(ka, kb);
        if (kmax == 0)
        {
            return horimax + vertmax;
        }
        var ans = long.MaxValue;
        for (var ai = 0; ai <= horimax; ++ai)
        {
            if (ai == 0 && kb == 0) continue;
            var ok = h * w;
            var ng = -1L;
            while (ok - ng > 1)
            {
                var mid = (ok + ng) / 2;
                var hs = Math.Min(h, ai * la);
                var ws = Math.Min(w, mid * lb);
                var cnt = hs * ws + ai * ka + mid * kb;
                if (cnt >= h * w) ok = mid;
                else ng = mid;
            }
            ans = Math.Min(ans, ai + ok);
        }
        for (var bi = 0; bi <= vertmax; ++bi)
        {
            if (bi == 0 && ka == 0) continue;
            var ok = h * w;
            var ng = -1L;
            while (ok - ng > 1)
            {
                var mid = (ok + ng) / 2;
                var hs = Math.Min(h, mid * la);
                var ws = Math.Min(w, bi * lb);
                var cnt = hs * ws + bi * kb + mid * ka;
                if (cnt >= h * w) ok = mid;
                else ng = mid;
            }
            ans = Math.Min(ans, bi + ok);
        }
        return ans;
    }
}
0