結果
問題 | No.2227 King Kraken's Attack |
ユーザー | kakel-san |
提出日時 | 2023-02-25 00:06:08 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 1,647 ms / 2,000 ms |
コード長 | 2,127 bytes |
コンパイル時間 | 1,142 ms |
コンパイル使用メモリ | 107,008 KB |
実行使用メモリ | 19,072 KB |
最終ジャッジ日時 | 2024-10-02 11:31:19 |
合計ジャッジ時間 | 15,603 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 28 ms
18,944 KB |
testcase_01 | AC | 28 ms
18,944 KB |
testcase_02 | AC | 28 ms
18,944 KB |
testcase_03 | AC | 32 ms
18,944 KB |
testcase_04 | AC | 28 ms
18,816 KB |
testcase_05 | AC | 27 ms
18,688 KB |
testcase_06 | AC | 27 ms
18,944 KB |
testcase_07 | AC | 27 ms
19,072 KB |
testcase_08 | AC | 28 ms
18,944 KB |
testcase_09 | AC | 28 ms
18,688 KB |
testcase_10 | AC | 28 ms
18,816 KB |
testcase_11 | AC | 28 ms
18,944 KB |
testcase_12 | AC | 28 ms
18,816 KB |
testcase_13 | AC | 27 ms
18,944 KB |
testcase_14 | AC | 27 ms
18,944 KB |
testcase_15 | AC | 27 ms
18,944 KB |
testcase_16 | AC | 27 ms
18,944 KB |
testcase_17 | AC | 844 ms
18,688 KB |
testcase_18 | AC | 88 ms
18,944 KB |
testcase_19 | AC | 27 ms
18,944 KB |
testcase_20 | AC | 1,232 ms
18,816 KB |
testcase_21 | AC | 1,112 ms
18,816 KB |
testcase_22 | AC | 393 ms
18,816 KB |
testcase_23 | AC | 57 ms
18,944 KB |
testcase_24 | AC | 762 ms
18,816 KB |
testcase_25 | AC | 728 ms
18,816 KB |
testcase_26 | AC | 1,647 ms
18,944 KB |
testcase_27 | AC | 105 ms
18,944 KB |
testcase_28 | AC | 895 ms
18,560 KB |
testcase_29 | AC | 890 ms
18,944 KB |
testcase_30 | AC | 954 ms
18,944 KB |
testcase_31 | AC | 834 ms
18,944 KB |
testcase_32 | AC | 365 ms
18,944 KB |
testcase_33 | AC | 316 ms
18,688 KB |
testcase_34 | AC | 244 ms
19,072 KB |
testcase_35 | AC | 400 ms
18,944 KB |
testcase_36 | AC | 426 ms
18,816 KB |
testcase_37 | AC | 56 ms
18,688 KB |
testcase_38 | AC | 46 ms
18,816 KB |
testcase_39 | AC | 54 ms
19,072 KB |
testcase_40 | AC | 57 ms
19,072 KB |
testcase_41 | AC | 75 ms
19,072 KB |
testcase_42 | AC | 44 ms
18,816 KB |
testcase_43 | AC | 62 ms
18,688 KB |
testcase_44 | AC | 84 ms
18,944 KB |
testcase_45 | AC | 27 ms
19,072 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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; 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 = (kb == 0 ? h * w : (h * w + kb - 1) / kb); 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 = (ka == 0 ? h * w : (h * w + ka - 1) / ka); 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; } }