結果

問題 No.3023 Utility is Max?
ユーザー Vincent Shaw
提出日時 2025-02-14 21:38:27
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 1,051 bytes
コンパイル時間 97 ms
コンパイル使用メモリ 12,160 KB
実行使用メモリ 73,480 KB
最終ジャッジ日時 2025-02-14 21:39:01
合計ジャッジ時間 10,277 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 1 WA * 16
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
data = sys.stdin.read().split()
if not data:
    sys.exit(0)
it = iter(data)
Q = int(next(it))
ans = []
for _ in range(Q):
    I = int(next(it))
    # 店1のデータ: A_i^1, B_i^1, X_i^1, Y_i^1
    A1 = int(next(it)); B1 = int(next(it)); X1 = int(next(it)); Y1 = int(next(it))
    # 店2のデータ: A_i^2, B_i^2, X_i^2, Y_i^2
    A2 = int(next(it)); B2 = int(next(it)); X2 = int(next(it)); Y2 = int(next(it))
    
    cost1 = A1 * X1 + B1 * Y1
    cost2 = A2 * X2 + B2 * Y2
    
    # (1) 各店で予算を使い切っているか
    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 or cross2 > I:
        ans.append("Yes")
    else:
        ans.append("No")
        
sys.stdout.write("\n".join(ans) + "\n")
0