結果

問題 No.2227 King Kraken's Attack
ユーザー 👑 kakel-sankakel-san
提出日時 2023-02-24 23:46:40
言語 C#(csc)
(csc 3.9.0)
結果
RE  
実行時間 -
コード長 2,094 bytes
コンパイル時間 1,492 ms
コンパイル使用メモリ 112,024 KB
実行使用メモリ 27,448 KB
最終ジャッジ日時 2024-04-10 09:40:29
合計ジャッジ時間 19,782 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
25,248 KB
testcase_01 AC 30 ms
25,116 KB
testcase_02 AC 30 ms
25,248 KB
testcase_03 AC 35 ms
27,288 KB
testcase_04 AC 30 ms
25,232 KB
testcase_05 AC 30 ms
27,276 KB
testcase_06 AC 29 ms
27,144 KB
testcase_07 AC 29 ms
25,116 KB
testcase_08 AC 29 ms
27,448 KB
testcase_09 AC 29 ms
25,112 KB
testcase_10 AC 29 ms
25,228 KB
testcase_11 AC 29 ms
25,372 KB
testcase_12 AC 30 ms
27,024 KB
testcase_13 AC 33 ms
25,108 KB
testcase_14 AC 29 ms
27,276 KB
testcase_15 AC 29 ms
27,028 KB
testcase_16 AC 29 ms
27,156 KB
testcase_17 AC 1,621 ms
27,028 KB
testcase_18 RE -
testcase_19 AC 29 ms
27,284 KB
testcase_20 AC 1,487 ms
25,240 KB
testcase_21 AC 1,535 ms
25,232 KB
testcase_22 AC 412 ms
25,116 KB
testcase_23 AC 59 ms
25,264 KB
testcase_24 AC 840 ms
24,876 KB
testcase_25 RE -
testcase_26 AC 1,717 ms
27,148 KB
testcase_27 RE -
testcase_28 AC 1,496 ms
27,144 KB
testcase_29 AC 1,488 ms
25,264 KB
testcase_30 AC 1,541 ms
25,116 KB
testcase_31 AC 1,322 ms
27,028 KB
testcase_32 AC 681 ms
22,972 KB
testcase_33 AC 559 ms
25,228 KB
testcase_34 AC 417 ms
27,160 KB
testcase_35 AC 719 ms
25,244 KB
testcase_36 AC 701 ms
25,116 KB
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 AC 29 ms
25,116 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 ans = horimax + vertmax;
        checked
        {
        var kmax = Math.Max(ka, kb);
        if (kmax == 0)
        {
            return ans;
        }
        if (ka > 0) ans = Math.Min(ans, (h * w + ka - 1) / ka);
        if (kb > 0) ans = Math.Min(ans, (h * w + kb - 1) / kb);
        for (var ai = 0; ai <= h; ++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 <= w; ++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