結果
| 問題 |
No.3023 Utility is Max?
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-14 21:34:16 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,040 bytes |
| コンパイル時間 | 275 ms |
| コンパイル使用メモリ | 12,288 KB |
| 実行使用メモリ | 85,600 KB |
| 最終ジャッジ日時 | 2025-02-14 21:35:07 |
| 合計ジャッジ時間 | 10,605 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 1 WA * 16 |
ソースコード
import sys
input_data = sys.stdin.read().strip().split()
if not input_data:
sys.exit(0)
it = iter(input_data)
Q = int(next(it))
ans = []
for _ in range(Q):
I = int(next(it))
# 店1 のデータ
A1 = int(next(it)); B1 = int(next(it)); X1 = int(next(it)); Y1 = int(next(it))
# 店2 のデータ
A2 = int(next(it)); B2 = int(next(it)); X2 = int(next(it)); Y2 = int(next(it))
# (1) 各店舗で予算を使い切っているか
cost1 = A1 * X1 + B1 * Y1
cost2 = A2 * X2 + B2 * Y2
if cost1 != I or cost2 != I:
ans.append("No")
continue
# (2) クロスで相手の指定量が予算内に収まってしまうと両店舗で互いの指定量が
# 購入可能になり矛盾する
cross1 = A1 * X2 + B1 * Y2 # 店2の指定量が店1の予算で買えるか
cross2 = A2 * X1 + B2 * Y1 # 店1の指定量が店2の予算で買えるか
if cross1 <= I and cross2 <= I:
ans.append("No")
else:
ans.append("Yes")
sys.stdout.write("\n".join(ans) + "\n")