結果
問題 | No.846 メダル |
ユーザー |
![]() |
提出日時 | 2025-03-20 21:02:10 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 39 ms / 2,000 ms |
コード長 | 1,391 bytes |
コンパイル時間 | 148 ms |
コンパイル使用メモリ | 82,356 KB |
実行使用メモリ | 54,136 KB |
最終ジャッジ日時 | 2025-03-20 21:02:15 |
合計ジャッジ時間 | 1,968 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 22 |
ソースコード
P, Q, R = map(int, input().split())A, B, C = map(int, input().split())ranges = []# Case 1: B > 0 and C > 0if B > 0 and C > 0:L1 = (A - 1) * P + 1U1 = A * PL2 = (A + B - 1) * Q + 1U2 = (A + B) * QL3 = (A + B + C - 1) * R + 1U3 = (A + B + C) * Rlower = max(L1, L2, L3)upper = min(U1, U2, U3)if lower <= upper:ranges.append((lower, upper))# Case 2: B > 0 and C == 0if B > 0 and C == 0:L1 = (A - 1) * P + 1U1 = A * PL2 = (A + B - 1) * Q + 1U2 = (A + B) * Qupper_limit = (A + B) * R # N <= (A+B)*R to satisfy ceil(N/R) <= A+Blower = max(L1, L2)upper = min(U1, U2, upper_limit)if lower <= upper:ranges.append((lower, upper))# Case 3: B == 0 and C > 0if B == 0 and C > 0:L1 = (A - 1) * P + 1U1 = A * Pupper_Q_limit = A * Q # N <= A*Q for ceil(N/Q) <= AL3 = (A + C - 1) * R + 1U3 = (A + C) * Rlower = max(L1, L3)upper = min(U1, upper_Q_limit, U3)if lower <= upper:ranges.append((lower, upper))# Case 4: B == 0 and C == 0if B == 0 and C == 0:L1 = (A - 1) * P + 1upper_values = min(A * P, A * Q, A * R)if L1 <= upper_values:ranges.append((L1, upper_values))if not ranges:print(-1)else:min_n = min(r[0] for r in ranges)max_n = max(r[1] for r in ranges)print(min_n, max_n)