結果
問題 | No.2227 King Kraken's Attack |
ユーザー | kakel-san |
提出日時 | 2023-02-24 23:26:56 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 3,289 bytes |
コンパイル時間 | 2,141 ms |
コンパイル使用メモリ | 107,648 KB |
実行使用メモリ | 19,072 KB |
最終ジャッジ日時 | 2024-10-02 11:28:55 |
合計ジャッジ時間 | 25,624 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 24 ms
18,944 KB |
testcase_01 | AC | 23 ms
18,816 KB |
testcase_02 | AC | 24 ms
18,944 KB |
testcase_03 | AC | 27 ms
18,944 KB |
testcase_04 | AC | 23 ms
18,944 KB |
testcase_05 | AC | 23 ms
18,944 KB |
testcase_06 | AC | 24 ms
18,688 KB |
testcase_07 | AC | 26 ms
18,944 KB |
testcase_08 | AC | 25 ms
18,944 KB |
testcase_09 | AC | 26 ms
18,944 KB |
testcase_10 | AC | 25 ms
18,944 KB |
testcase_11 | AC | 24 ms
18,688 KB |
testcase_12 | AC | 23 ms
19,072 KB |
testcase_13 | AC | 24 ms
19,072 KB |
testcase_14 | AC | 24 ms
18,944 KB |
testcase_15 | AC | 23 ms
18,944 KB |
testcase_16 | AC | 24 ms
18,944 KB |
testcase_17 | AC | 1,330 ms
18,816 KB |
testcase_18 | WA | - |
testcase_19 | AC | 24 ms
18,816 KB |
testcase_20 | AC | 1,240 ms
18,944 KB |
testcase_21 | AC | 1,292 ms
18,944 KB |
testcase_22 | AC | 338 ms
18,816 KB |
testcase_23 | AC | 50 ms
18,816 KB |
testcase_24 | AC | 708 ms
19,072 KB |
testcase_25 | AC | 1,240 ms
18,688 KB |
testcase_26 | AC | 1,471 ms
19,072 KB |
testcase_27 | WA | - |
testcase_28 | AC | 1,263 ms
18,816 KB |
testcase_29 | AC | 1,264 ms
18,944 KB |
testcase_30 | AC | 1,448 ms
19,072 KB |
testcase_31 | AC | 1,124 ms
18,816 KB |
testcase_32 | AC | 568 ms
18,944 KB |
testcase_33 | AC | 465 ms
18,944 KB |
testcase_34 | AC | 350 ms
18,944 KB |
testcase_35 | AC | 600 ms
18,688 KB |
testcase_36 | AC | 590 ms
18,816 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 | 26 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 Test() { var r = new Random(); var count = 0; var max = 2000; while (true) { var h = r.Next(max) + 1; var w = r.Next(max) + 1; var la = r.Next(max) + 1; var lb = r.Next(max) + 1; var ka = r.Next(max); var kb = r.Next(max); // 愚直解 var s1 = All(h, w, la, lb, ka, kb); // 作成解 var s2 = Attack(h, w, la, lb, ka, kb); if (s1 != s2) { WriteLine($"{h} {w} {la} {lb} {ka} {kb}"); WriteLine(s1); WriteLine(s2); return; } ++count; if (count % 10 == 0) WriteLine(count); } } static long All(long h, long w, long la, long lb, long ka, long kb) { var ans = long.MaxValue; for (var ai = 0; Math.Max(ai, ai * ka) <= h * w + ka; ++ai) for (var bi = 0; Math.Max(bi, bi * kb) <= h * w + kb; ++bi) { var hs = Math.Min(h, ai * la); var ws = Math.Min(w, bi * lb); if (hs * ws + ai * ka + bi * kb >= h * w) ans = Math.Min(ans, ai + bi); } return ans; } 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; return horimax + vertmax; } var ans = long.MaxValue; 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; } }