結果
問題 |
No.2227 King Kraken's Attack
|
ユーザー |
![]() |
提出日時 | 2025-03-31 17:57:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,549 bytes |
コンパイル時間 | 270 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 76,416 KB |
最終ジャッジ日時 | 2025-03-31 17:58:21 |
合計ジャッジ時間 | 4,707 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 41 WA * 1 |
ソースコード
import math def minimal_punches(H, W, L_A, L_B, K_A, K_B): min_total = float('inf') A_max = (H + L_A - 1) // L_A # ceil(H / L_A) for a in range(0, A_max + 1): R = min(a * L_A, H) B_lim = W // L_B # Case 1: B <= B_lim, C = B*L_B <= W denominator_case1 = K_B + R * L_B required_case1 = H * W - a * K_A possible_B_case1 = None case1_possible = False if denominator_case1 == 0: if required_case1 <= 0: possible_B_case1 = 0 case1_possible = possible_B_case1 <= B_lim else: case1_possible = False else: if required_case1 <= 0: possible_B_case1 = 0 case1_possible = possible_B_case1 <= B_lim else: possible_B_case1 = (required_case1 + denominator_case1 - 1) // denominator_case1 possible_B_case1 = max(0, possible_B_case1) case1_possible = possible_B_case1 <= B_lim # Case 2: B >= ceil(W / L_B), C = W B2_candidate = (W + L_B - 1) // L_B required_case2 = W * (H - R) remaining = required_case2 - a * K_A if remaining <= 0: possible_B_case2 = B2_candidate case2_possible = True else: if K_B == 0: possible_B_case2 = float('inf') case2_possible = False else: possible_B_case2 = max(B2_candidate, (remaining + K_B - 1) // K_B) case2_possible = (a * K_A + possible_B_case2 * K_B) >= required_case2 # Case 3: B=0, check if possible case3_possible = (a * K_A >= H * W) possible_B_case3 = 0 # Collect all possible B options candidates_B = [] if case1_possible: candidates_B.append(possible_B_case1) if case2_possible and possible_B_case2 != float('inf'): candidates_B.append(possible_B_case2) if case3_possible: candidates_B.append(possible_B_case3) if not candidates_B: continue current_B = min(candidates_B) total = a + current_B if total < min_total: min_total = total return min_total if min_total != float('inf') else 0 # Read input H, W, L_A, L_B, K_A, K_B = map(int, input().split()) # Compute result result = minimal_punches(H, W, L_A, L_B, K_A, K_B) # Output the result print(result)